Quantcast
Viewing all articles
Browse latest Browse all 360

Commented Unassigned: Add PID-File for SBFspotUploadDaemon [93]

May you please add an option to create a PID-File for the SBFspotUploadDaemon.
I've done this actually by a wrapper script, but this sucks a little bit during upgrade process.

/usr/local/bin/sbfspot.3/SBFspotUploadDaemon.sh
```
#!/bin/bash
# start upload daemon
/usr/local/bin/sbfspot.3/SBFspotUploadDaemon

# write pid file
PID=`pidof SBFspotUploadDaemon`

echo "$PID" > /run/SBFspotUploadDaemon.pid
```

Maybe you can add this Init-Script for Debian based systems (also Raspberry PI). This took care for the PID-File and can start and stop the SBFspotUploadDaemon in a correct way. No more need for patching the /etc/rc.local.

```
#!/bin/sh

### BEGIN INIT INFO
# Provides: SBFspotUploadDaemon
# Required-Start:
# Required-Stop:
# Should-Start: $all
# Should-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: upload gathered data from SMA inverters
# Description:
#
#
#
### END INIT INFO

set -e

. /lib/lsb/init-functions

DAEMON=/usr/local/bin/sbfspot.3/SBFspotUploadDaemon.sh
NAME=SBFspotUploadDaemon
DESC="daemon upload"
PID="/run/$NAME.pid"
SBFUD_OPTS=""

# Check if DAEMON binary exist
[ -f $DAEMON ] || exit 0

[ -f "/etc/default/$NAME" ] && . /etc/default/$NAME

case "$1" in
start)
log_daemon_msg "Starting $DESC" "$NAME"
if start-stop-daemon --start --quiet --oknodo --pidfile $PID --exec $DAEMON -- $SBFUD_OPTS 1>/dev/null
then
log_end_msg 0
else
log_end_msg 1
fi
;;
stop)
log_daemon_msg "Stopping $DESC" "$NAME"
if start-stop-daemon --retry TERM/5/KILL/5 --oknodo --stop --quiet --pidfile $PID 1>/dev/null
then
log_end_msg 0
else
log_end_msg 1
fi
;;
restart|force-reload)
log_daemon_msg "Restarting $DESC" "$NAME"
start-stop-daemon --retry TERM/5/KILL/5 --oknodo --stop --quiet --pidfile $PID 1>/dev/null
if start-stop-daemon --start --quiet --oknodo --pidfile $PID --exec $DAEMON -- $SBFUD_OPTS 1>/dev/null
then
log_end_msg 0
else
log_end_msg 1
fi
;;
status)
status_of_proc -p $PID $DAEMON $NAME
;;
*)
log_action_msg "Usage: /etc/init.d/$NAME {start|stop|restart|force-reload|status}"
;;
esac

exit 0
```

Additional benefit, process is now monitorable by Monit with the following modification done to /etc/monit/monitrc

```
...
check process SBFspotUploadDaemon with pidfile /run/SBFspotUploadDaemon.pid
start program = "/etc/init.d/SBFspotUploadDaemon start"
stop program = "/etc/init.d/SBFspotUploadDaemon stop"
...
```

Think this would be helpful to improve this great software.
Comments: Hello, Is the PID-patch meanwhile included in the official v3.3.1 package or do I need to add by myself...?

Viewing all articles
Browse latest Browse all 360

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>