Code

HTTP-Server can now daemonize
[nagixsc.git] / nagixsc_http2nagios.py
index ad86b65eba536feb843e40198c1f06af8a55a11d..e327bc18f46368e9017859848f4d8ac2d1e43e5a 100755 (executable)
@@ -22,6 +22,7 @@ from nagixsc import *
 parser = optparse.OptionParser()
 
 parser.add_option('-c', '', dest='cfgfile', help='Config file')
+parser.add_option('-d', '--daemon', action='store_true', dest='daemon', help='Daemonize, go to background')
 parser.add_option('', '--nossl', action='store_true', dest='nossl', help='Disable SSL (overwrites config file)')
 
 parser.set_defaults(cfgfile='http2nagios.cfg')
@@ -129,6 +130,9 @@ def main():
                print 'SSL certificate "%s" not found!' % config['cert']
                sys.exit(127)
 
+       if options.daemon:
+               daemonize(pidfile='/var/run/nagixsc_http2nagios.pid')
+
        server = MyHTTPServer((config['ip'], config['port']), HTTP2NagiosHandler, ssl=config['ssl'], sslpemfile=config['cert'])
        try:
                server.serve_forever()