So I whipped up a quick init.d script for openLuup, it works well for me on debian based systems.
To use it (some knowledge of Linux is assumed with the below commands):
create a file “openLuup” in /etc/init.d using your editor of choice
copy / paste script from below & save the file
make the file executable
test it, make sure you’re happy with it (/etc/init.d/openLuup start)
execute “update-rc.d openLuup defaults” to activate it on start / stop of Linux
It supports “start/stop/restart/reload/kill”
Couple of notes:
I don’t think openLuup is Linux “signal” aware (at least it didn’t exit / restart cleanly when the process was sent signals). So it’s not possible to use traditional stop / start / reload methods (as I understand it, it’s very difficult to make lua stuff signal aware, so this likely won’t change). I used wget to call the exit / reload urls on localhost instead.
I like to run things like openLuup under a “screen” session as it means if they bomb out you should still be able to access the screen session and see any stdout / stderr fallout that may not make it into any log files. To resume the screen session use “screen -R -d -r openLuup” (will likely be a blank screen unless openLuup is outputting anything to stdout / stderr at the time).
Tail your log file using “tail -F /etc/cmh-ludl/LuaUPnP.log” - capital “F” makes tail follow the log file continuously and also re-open the file if it get’s rotated.
I’d love to incorporate this into the step-by-step guides I’ve been giving out which supplements Akbooer’s guide. When I get some time I’d like to try this out and I might have some questions although you’ve done a great job of describing everything.
Certainly no problem to include this, or similar, in the distribution, although it would not work on my Yun which doesn’t out-of-the-box have the screen command.
I’m trying to use this with the Z way server, but the problem is that this starts too quickly - before the Z way server has started up. Any idea how to make this dependent on the Z way server starting up? I believe systemd may handle dependencies, but I haven’t looked at it much. Is that a better approach?
This worked for me. I added the z-way-server to the dependencies and added a sleep. I also added a variable for the openLuup location. And I made it run as ‘pi’ instead of root.
[code]#! /bin/sh
Starts and stops openLuup
/etc/init.d/openLuup
BEGIN INIT INFO
Provides: openLuup
Required-Start: $syslog z-way-server
Required-Stop: $syslog
Default-Start: 2 3 4 5
Default-Stop: 0 1 6
Short-Description: openLuup
END INIT INFO
OPENLUUP_HOME=“/home/pi/LuaDevZway”
#Load up openLuup when called
case “$1” in
start)
echo “Starting openLuup in 10 seconds…”
# sleep 10 in order to let Z way server startup
sleep 10
# cd /etc/cmh-ludl
cd $OPENLUUP_HOME
# sudo screen -dmS openLuup ./openLuup_reload
# run as pi
su -c ‘screen -dmS openLuup ./openLuup_reload’ pi
echo “ok”
;;
stop)
echo “Stopping openLuup…”
# sudo wget -q -t 1 -T 5 http://127.0.0.1:3480/data_request?id=exit
wget -q -t 1 -T 5 http://127.0.0.1:3480/data_request?id=exit
echo “ok”
;;
kill)
echo “Killing openLuup…”
# sudo screen -S openLuup -X quit
screen -S openLuup -X quit
echo “ok”
;;
restart)
echo “Restarting openLuup…”
$0 stop
$0 start
;;
reload)
echo “Reloading openLuup…”
# sudo wget -q -t 1 -T 5 http://127.0.0.1:3480/data_request?id=reload
wget -q -t 1 -T 5 http://127.0.0.1:3480/data_request?id=reload
echo “ok”
;;
*)
echo “Usage: $0 {start|stop|reload|restart|kill}”
exit 1
esac
[/code]
Thanks for this update. To be honest, I hardly ever reload or reboot my openLuup systems, so a hard-wired startup in rc.local works fine.
On the day that all my Vera systems reloaded together (ie. the start of the month) I just checked the uptime of the openLuup systems… my RPi one has been running without a reload for just 100 days! See attached.
Having reached this significant milestone I now do need to take it down to install a MySensors radio gateway since my Arduino Yun system bit the dust (down forever!) so maybe I’ll try out this script anyway.
Yes, much appreciated @jswim788… Once I get some bandwidth I’d like to add this to the turn-key’s. I too hardly ever operate openLuup at the CLI anymore (load and go right !). I still smile every time I get into the UI and discover I’ve been up for weeks or months. It’s a wonderful thing !
[quote=“jswim788, post:6, topic:190501”]This worked for me. I added the z-way-server to the dependencies and added a sleep. I also added a variable for the openLuup location. And I made it run as ‘pi’ instead of root.
[code]#! /bin/sh
Starts and stops openLuup
/etc/init.d/openLuup
BEGIN INIT INFO
Provides: openLuup
Required-Start: $syslog z-way-server
Required-Stop: $syslog
Default-Start: 2 3 4 5
Default-Stop: 0 1 6
Short-Description: openLuup
END INIT INFO
OPENLUUP_HOME=“/home/pi/LuaDevZway”
#Load up openLuup when called
case “$1” in
start)
echo “Starting openLuup in 10 seconds…”
# sleep 10 in order to let Z way server startup
sleep 10
# cd /etc/cmh-ludl
cd $OPENLUUP_HOME
# sudo screen -dmS openLuup ./openLuup_reload
# run as pi
su -c ‘screen -dmS openLuup ./openLuup_reload’ pi
echo “ok”
;;
stop)
echo “Stopping openLuup…”
# sudo wget -q -t 1 -T 5 http://127.0.0.1:3480/data_request?id=exit
wget -q -t 1 -T 5 http://127.0.0.1:3480/data_request?id=exit
echo “ok”
;;
kill)
echo “Killing openLuup…”
# sudo screen -S openLuup -X quit
screen -S openLuup -X quit
echo “ok”
;;
restart)
echo “Restarting openLuup…”
$0 stop
$0 start
;;
reload)
echo “Reloading openLuup…”
# sudo wget -q -t 1 -T 5 http://127.0.0.1:3480/data_request?id=reload
wget -q -t 1 -T 5 http://127.0.0.1:3480/data_request?id=reload
echo “ok”
;;
*)
echo “Usage: $0 {start|stop|reload|restart|kill}”
exit 1
esac
[/code][/quote]