From: Bernhard Tittelbach Date: Tue, 8 Oct 2013 23:16:37 +0000 (+0000) Subject: initscript and correct address X-Git-Url: https://git.realraum.at/?a=commitdiff_plain;h=911130b0471d8e4e77e398dd0442ca098885aed0;p=svn42.git initscript and correct address --- diff --git a/go/uc_sensor_node_zmq/main.go b/go/uc_sensor_node_zmq/main.go index 52a8aad..bd55297 100644 --- a/go/uc_sensor_node_zmq/main.go +++ b/go/uc_sensor_node_zmq/main.go @@ -13,21 +13,26 @@ var ( tty_dev_ string pub_addr string use_syslog_ bool + enable_debug_ bool ) func init() { - flag.StringVar(&pub_addr, "brokeraddr", "tcp://torwaechter.realraum.at:4244", "zmq address to send stuff to") + flag.StringVar(&pub_addr, "brokeraddr", "tcp://torwaechter.realraum.at:4243", "zmq address to send stuff to") flag.StringVar(&tty_dev_, "ttydev", "/dev/ttyACM0", "path do tty uc device") flag.BoolVar(&use_syslog_, "syslog", false, "log to syslog local1 facility") + flag.BoolVar(&enable_debug_, "debug", false, "debugging messages on") flag.Parse() } func main() { zmqctx, pub_sock := ZmqsInit(pub_addr) + if pub_sock == nil { panic("zmq socket creation failed") } defer zmqctx.Close() defer pub_sock.Close() - if use_syslog_ { + if enable_debug_ { + LogEnableDebuglog() + } else if use_syslog_ { LogEnableSyslog() Syslog_.Print("started") } diff --git a/uc_sensor_node_zmq.initscript b/uc_sensor_node_zmq.initscript new file mode 100755 index 0000000..a3dec6c --- /dev/null +++ b/uc_sensor_node_zmq.initscript @@ -0,0 +1,53 @@ +#!/bin/sh +# Start/stop the tuer status updater. +# +### BEGIN INIT INFO +# Provides: uc_sensor_node_zmq +# Required-Start: $remote_fs $syslog $time +# Required-Stop: $remote_fs $syslog $time +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +### END INIT INFO + +EXE_NODE=/home/realraum/uc_sensor_node_zmq +CFG_NODE="" +DIR_RUN=/var/run +DOOR_USR=realraum +DOOR_GRP=nogroup + +#. /etc/default/tuer + +PIDFILE_NODE=/var/run/uc_sensor_node_zmq.pid + +test -f $EXE_NODE || exit 1 +if [ ! -d $DIR_RUN ]; then + mkdir -p $DIR_RUN || exit 2 + chown -R $DOOR_USR:$DOOR_GRP $DIR_RUN +fi + +. /lib/lsb/init-functions + +# Read the system's locale and set cron's locale. This locale +# will be inherited by cron (used to set charset of emails) +# and tasks running under it. + +case "$1" in +start) + log_daemon_msg "Starting daemon" uc_sensor_node_zmq + start-stop-daemon --start --quiet --pidfile $PIDFILE_NODE -b -m -c $DOOR_USR --startas $EXE_NODE -- $CFG_NODE + log_end_msg $? + ;; +stop) + log_daemon_msg "Stopping daemon" uc_sensor_node_zmq + start-stop-daemon --stop --quiet --pidfile $PIDFILE_NODE -m --retry TERM/1/TERM/1/KILL + log_end_msg $? + ;; +restart) + $0 stop + $0 start + ;; +*) log_action_msg "Usage: $0 {start|stop|restart|reload|force-reload}" + exit 2 + ;; +esac +exit 0