Skip to content
Snippets Groups Projects
Commit 4e804cc3 authored by Anael Beutot's avatar Anael Beutot
Browse files

Fix daemonization, close stderr/stdout in non debug mode

parent 1315ef40
No related branches found
No related tags found
No related merge requests found
......@@ -10,6 +10,7 @@ from daemon import DaemonContext
from cloudcontrol.node import __version__
from cloudcontrol.node.node import NodeLoop
from cloudcontrol.node.config import NodeConfigParser
DEFAULT_CONFIG_FILE = '/etc/cc-node.conf'
......@@ -33,6 +34,7 @@ if options.daemonize and not options.pidfile:
options.config = abspath(options.config)
if not isfile(options.config):
sys.exit(u'Please supply a valid path to configuration file...')
config = NodeConfigParser(options.config)
# take care of pid file if daemon
......@@ -42,10 +44,17 @@ if options.daemonize:
else:
files_preserve = None
if config.debug:
stderr = sys.stderr
stdout = sys.stdout
else:
stderr = None
stdout = None
with DaemonContext(detach_process=options.daemonize,
files_preserve=files_preserve,
stderr=sys.stderr,
stdout=sys.stdout):
stderr=stderr,
stdout=stdout):
# take care of pidfile
if options.daemonize:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment