Commit c84b8405 authored by Joe Nahmias's avatar Joe Nahmias Committed by Keith Packard

use python-daemon to daemonize calypso

parent 5035efc3
...@@ -36,10 +36,11 @@ arguments. ...@@ -36,10 +36,11 @@ arguments.
# TODO: Manage smart and configurable logs # TODO: Manage smart and configurable logs
import daemon
import logging import logging
import optparse
import os import os
import sys import sys
import optparse
import calypso import calypso
import calypso.webdav as webdav import calypso.webdav as webdav
...@@ -132,14 +133,22 @@ if options.import_dest: ...@@ -132,14 +133,22 @@ if options.import_dest:
else: else:
sys.exit(1) sys.exit(1)
# Fork if Calypso is launched as daemon def run_server():
if options.daemon: # Launch server
if os.fork(): server_class = calypso.HTTPSServer if options.ssl else calypso.HTTPServer
sys.exit() server = server_class(
sys.stdout = sys.stderr = open(os.devnull, "w")
# Launch server
server_class = calypso.HTTPSServer if options.ssl else calypso.HTTPServer
server = server_class(
(, options.port), calypso.CollectionHTTPHandler) (, options.port), calypso.CollectionHTTPHandler)
server.serve_forever(poll_interval=10) server.serve_forever(poll_interval=10)
# If foreground execution is requested, just run the server
if not options.daemon:
# Otherwise, daemonize Calypso
context = daemon.DaemonContext()
context.umask = 0o002
with context:
# vim: set ts=4 sw=4 et si :
...@@ -77,7 +77,7 @@ setup( ...@@ -77,7 +77,7 @@ setup(
platforms="Any", platforms="Any",
packages=["calypso", "calypso.acl"], packages=["calypso", "calypso.acl"],
provides=["calypso"], provides=["calypso"],
install_requires=["vobject",], install_requires=["daemon","vobject"],
scripts=[""], scripts=[""],
cmdclass={"build_scripts": BuildScripts}, cmdclass={"build_scripts": BuildScripts},
keywords=["calendar", "CalDAV"], keywords=["calendar", "CalDAV"],
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment