initscript and correct address
authorBernhard Tittelbach <xro@realraum.at>
Tue, 8 Oct 2013 23:16:37 +0000 (23:16 +0000)
committerBernhard Tittelbach <xro@realraum.at>
Tue, 8 Oct 2013 23:16:37 +0000 (23:16 +0000)
go/uc_sensor_node_zmq/main.go
uc_sensor_node_zmq.initscript [new file with mode: 0755]

index 52a8aad..bd55297 100644 (file)
@@ -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 (executable)
index 0000000..a3dec6c
--- /dev/null
@@ -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