|
@@ -8,6 +8,7 @@
|
|
|
import datetime
|
|
|
import time
|
|
|
import sys
|
|
|
+import signal
|
|
|
from optparse import OptionParser
|
|
|
|
|
|
import stddlib.daemon
|
|
@@ -35,12 +36,35 @@ parser.add_option("-c", "--config", dest="config", help="define an\
|
|
|
alternative path to the configuration file")
|
|
|
(options, arguments) = parser.parse_args()
|
|
|
|
|
|
+""" define a sighandler to properly catch signals """
|
|
|
+
|
|
|
+
|
|
|
run = True
|
|
|
|
|
|
""" create the configuration object according to the given parameters and
|
|
|
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()
|
|
|
if options.config is not None:
|
|
|
config.Read(options.config)
|
|
@@ -49,7 +73,10 @@ else:
|
|
|
config.Analyze()
|
|
|
|
|
|
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.Start()
|
|
|
cmdline = ""
|