Refactor: Extract daemonize function
This commit is contained in:
parent
a94a3bc7c2
commit
79bcedd4bc
@ -114,9 +114,8 @@ def run():
|
|||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
|
|
||||||
def serve(configuration, logger):
|
def daemonize(configuration, logger):
|
||||||
"""Serve radicale from configuration."""
|
"""Fork and decouple if Radicale is configured as daemon."""
|
||||||
# Fork if Radicale is launched as daemon
|
|
||||||
if configuration.getboolean("server", "daemon"):
|
if configuration.getboolean("server", "daemon"):
|
||||||
# Check and create PID file in a race-free manner
|
# Check and create PID file in a race-free manner
|
||||||
if configuration.get("server", "pid"):
|
if configuration.get("server", "pid"):
|
||||||
@ -153,6 +152,11 @@ def serve(configuration, logger):
|
|||||||
os.unlink(configuration.get("server", "pid"))
|
os.unlink(configuration.get("server", "pid"))
|
||||||
|
|
||||||
atexit.register(cleanup)
|
atexit.register(cleanup)
|
||||||
|
|
||||||
|
|
||||||
|
def serve(configuration, logger):
|
||||||
|
"""Serve radicale from configuration."""
|
||||||
|
daemonize(configuration, logger)
|
||||||
logger.info("Starting Radicale")
|
logger.info("Starting Radicale")
|
||||||
|
|
||||||
# Create collection servers
|
# Create collection servers
|
||||||
|
Loading…
x
Reference in New Issue
Block a user