|
@@ -8,6 +8,7 @@
|
|
import datetime
|
|
import datetime
|
|
import time
|
|
import time
|
|
import sys
|
|
import sys
|
|
|
|
+import signal
|
|
from optparse import OptionParser
|
|
from optparse import OptionParser
|
|
|
|
|
|
import stddlib.daemon
|
|
import stddlib.daemon
|
|
@@ -35,12 +36,35 @@ parser.add_option("-c", "--config", dest="config", help="define an\
|
|
alternative path to the configuration file")
|
|
alternative path to the configuration file")
|
|
(options, arguments) = parser.parse_args()
|
|
(options, arguments) = parser.parse_args()
|
|
|
|
|
|
|
|
+""" define a sighandler to properly catch signals """
|
|
|
|
+
|
|
|
|
+
|
|
run = True
|
|
run = True
|
|
|
|
|
|
""" create the configuration object according to the given parameters and
|
|
""" create the configuration object according to the given parameters and
|
|
read the file itself
|
|
read the file itself
|
|
|
|
|
|
"""
|
|
"""
|
|
|
|
+
|
|
|
|
+def sighandler(signum, frame):
|
|
|
|
+ if signum == 2:
|
|
|
|
+ pass
|
|
|
|
+ elif signum == 15:
|
|
|
|
+ pass
|
|
|
|
+ display.writeDigit(0, 0)
|
|
|
|
+ display.writeDigit(1, 0)
|
|
|
|
+ display.writeDigit(3, 0)
|
|
|
|
+ display.writeDigit(4, 0)
|
|
|
|
+ if options.daemon is True:
|
|
|
|
+ if daemon.Stop() is True:
|
|
|
|
+ sys.exit(0)
|
|
|
|
+ else:
|
|
|
|
+ #TODO: Log error message
|
|
|
|
+ sys,exit(1)
|
|
|
|
+
|
|
|
|
+signal.signal(signal.SIGTERM, sighandler)
|
|
|
|
+signal.signal(signal.SIGINT, sighandler)
|
|
|
|
+
|
|
config = stddlib.configuration.Conf()
|
|
config = stddlib.configuration.Conf()
|
|
if options.config is not None:
|
|
if options.config is not None:
|
|
config.Read(options.config)
|
|
config.Read(options.config)
|
|
@@ -49,7 +73,10 @@ else:
|
|
config.Analyze()
|
|
config.Analyze()
|
|
|
|
|
|
if options.daemon is True:
|
|
if options.daemon is True:
|
|
- daemon = stddlib.daemon.Daemon("/var/run", "stdd")
|
|
|
|
|
|
+ if os.access("/run", os.F_OK & os.W_OK) is True:
|
|
|
|
+ daemon = stddlib.daemon.Daemon("/run", "stdd")
|
|
|
|
+ else:
|
|
|
|
+ daemon = stddlib.daemon.Daemon("/var/run", "stdd")
|
|
daemon.Daemonize()
|
|
daemon.Daemonize()
|
|
daemon.Start()
|
|
daemon.Start()
|
|
cmdline = ""
|
|
cmdline = ""
|