From: realraum Date: Thu, 17 Sep 2009 22:16:48 +0000 (+0000) Subject: getrennt und funktionell X-Git-Url: https://git.realraum.at/?a=commitdiff_plain;h=d263eec6d21cd566c06b2f1038cdce967c7cf8a8;p=svn42.git getrennt und funktionell --- diff --git a/tuer.initscript b/tuer.initscript index ba7a0f5..a07edf0 100755 --- a/tuer.initscript +++ b/tuer.initscript @@ -12,9 +12,11 @@ EXE_DOOR=/flash/tuer/door_daemon EXE_CARD=/flash/tuer/checkcard.pl EXE_UWEB=/flash/tuer/update-web-status.py +EXE_XMPP=/flash/tuer/update-xmpp-status.py DIR_RUN=/var/run/tuer CFG_UWEB=/flash/tuer/update-web-status.cfg +CFG_XMPP=/flash/tuer/update-xmpp-status.cfg DOOR_SOCKET=${DIR_RUN}/door_cmd.socket DOOR_DEV=/dev/door @@ -26,6 +28,7 @@ DOOR_GRP=nogroup PIDFILE1=${DIR_RUN}/door_daemon.pid PIDFILE2=${DIR_RUN}/checkcard.pid PIDFILE3=${DIR_RUN}/update-web-status.pid +PIDFILE4=${DIR_RUN}/update-xmpp-status.pid test -f $EXE_DOOR || exit 1 test -f $EXE_CARD || exit 1 @@ -53,6 +56,9 @@ start) log_daemon_msg "Starting door daemon" "update-web-status" start-stop-daemon --start --quiet --pidfile $PIDFILE3 -b -m -c $DOOR_USR --name update-web-status.py --startas $EXE_UWEB -- $DOOR_SOCKET $CFG_UWEB log_end_msg $? + log_daemon_msg "Starting door daemon" "update-xmpp-status" + start-stop-daemon --start --quiet --pidfile $PIDFILE4 -b -m -c $DOOR_USR --name update-xmpp-status.py --startas $EXE_XMPP -- $DOOR_SOCKET $CFG_XMPP + log_end_msg $? ;; stop) log_daemon_msg "Stopping door daemon" "door_daemon" @@ -64,6 +70,9 @@ stop) log_daemon_msg "Stopping door daemon" "update-web-status" start-stop-daemon --stop --quiet --pidfile $PIDFILE3 -m --retry TERM/1/TERM/1/KILL log_end_msg $? + log_daemon_msg "Stopping door daemon" "update-xmpp-status" + start-stop-daemon --stop --quiet --pidfile $PIDFILE4 -m --retry TERM/1/TERM/1/KILL + log_end_msg $? killall "mifare-read" 2>/dev/null ;; restart) diff --git a/update-web-status.py b/update-web-status.py index 7e928bb..11a6d5e 100755 --- a/update-web-status.py +++ b/update-web-status.py @@ -5,6 +5,7 @@ import os.path import sys #import threading import logging +import logging.handlers import urllib import time import signal @@ -14,14 +15,13 @@ import subprocess import types import ConfigParser -logging.basicConfig( - level=logging.INFO, - #level=f, - #level=logging.DEBUG, - filename='/var/log/tmp/update-web-status.log', - format="%(asctime)s %(message)s", - datefmt="%Y-%m-%d %H:%M:%S" - ) +logger = logging.getLogger() +logger.setLevel(logging.INFO) +lh_syslog = logging.handlers.SysLogHandler(address="/dev/log",facility=logging.handlers.SysLogHandler.LOG_LOCAL2) +lh_syslog.setFormatter(logging.Formatter('update-web-status.py: %(levelname)s %(message)s')) +logger.addHandler(lh_syslog) +lh_stderr = logging.StreamHandler() +logger.addHandler(lh_stderr) class UWSConfig: def __init__(self,configfile=None): @@ -139,7 +139,7 @@ def touchURL(url): f.read() f.close() except Exception, e: - logging.error("tochURL: "+str(e)) + logging.error("touchURL: "+str(e)) def displayOpen(): touchURL(uwscfg.url_open) diff --git a/update-webxmpp-status.py b/update-webxmpp-status.py index 0891ebc..328183d 100755 --- a/update-webxmpp-status.py +++ b/update-webxmpp-status.py @@ -153,7 +153,7 @@ def sendXmppMsg(recipients, msg, resource = "torwaechter", addtimestamp = True, if resource: sendxmpp_cmd += "-r %s " % resource if noofflinemsg: - sendxmpp_cmd += "--headline " + sendxmpp_cmd += "--message-type=headline " sendxmpp_cmd += recipients if addtimestamp: diff --git a/update-xmpp-status.py b/update-xmpp-status.py index 2c40cf2..116db82 100644 --- a/update-xmpp-status.py +++ b/update-xmpp-status.py @@ -5,6 +5,7 @@ import os.path import sys #import threading import logging +import logging.handlers import urllib import time import signal @@ -14,14 +15,14 @@ import subprocess import types import ConfigParser -logging.basicConfig( - level=logging.INFO, - #level=f, - #level=logging.DEBUG, - filename='/var/log/tmp/update-xmpp-status.log', - format="%(asctime)s %(message)s", - datefmt="%Y-%m-%d %H:%M:%S" - ) +logger = logging.getLogger() +logger.setLevel(logging.INFO) +#logger.setLevel(logging.DEBUG) +lh_syslog = logging.handlers.SysLogHandler(address="/dev/log",facility=logging.handlers.SysLogHandler.LOG_LOCAL2) +lh_syslog.setFormatter(logging.Formatter('update-xmpp-status.py: %(levelname)s %(message)s')) +logger.addHandler(lh_syslog) +lh_stderr = logging.StreamHandler() +logger.addHandler(lh_stderr) class UWSConfig: def __init__(self,configfile=None): @@ -150,7 +151,7 @@ def sendXmppMsg(recipients, msg, resource = "torwaechter", addtimestamp = True, if resource: sendxmpp_cmd += "-r %s " % resource if noofflinemsg: - sendxmpp_cmd += "--headline " + sendxmpp_cmd += "--message-type=headline " sendxmpp_cmd += recipients if addtimestamp: @@ -181,7 +182,7 @@ def touchURL(url): f.read() f.close() except Exception, e: - logging.error("tochURL: "+str(e)) + logging.error("touchURL: "+str(e)) def displayOpen(): distributeXmppMsg(uwscfg.xmpp_msg_opened % action_by)