]> git.ipfire.org Git - collecty.git/blobdiff - collectyd
Get rid of python-daemon. Properly handle signals.
[collecty.git] / collectyd
index 38bfe7e6041363c322a4847c181c5172ae18f884..ae0f6080acaf72d6ba6347965819656a145c7268 100755 (executable)
--- a/collectyd
+++ b/collectyd
 #                                                                             #
 ###############################################################################
 
-import os
-import sys
-
-import daemon
 import optparse
+import sys
 
 import collecty
 
-c = collecty.Collecty()
-
-# Parse command line options
+# Parse command line options.
 op = optparse.OptionParser(usage="usage: %prog [options] <configfile1> ... <configfileN>")
 op.add_option("-d", "--daemon", action="store_true", default=False,
                help="Run as a daemon in background.")
 (options, configfiles) = op.parse_args()
 
-if configfiles:
-       for file in configfiles:
-               c.read_config(file)
-else:
-       # Load default config file
-       c.read_config("/etc/collecty/collecty.conf")
-
-if not c.instances:
-       print >>sys.stderr, "Error: No instances were configured."
-       sys.exit(1)
+# Initialize the application.
+c = collecty.Collecty()
 
-if options.daemon:
-       with daemon.DaemonContext(stdout=sys.stdout, stderr=sys.stderr):
-               c.run()
-else:
-       c.run()
+# Run.
+c.run()
 
+sys.exit(0)