Hello all,
Does anyone have a sample init.d script that contains the start, stop, restart commands that the sample xojo code also looks for? There are many samples on the web, but I’ve been unsuccessful in getting the pair I have tried to work without what I think is “forcing” the app to start. Forcing is remarking code in the project
#If TargetLinux Or TargetARM Then // Daemonize
#If Not DebugBuild Then // Do not try to daemonize a debug build
System.Log( System.LogLevelCritical, "Trying to daemonize the Axcys application.")
If (args(1) = "start" Or args(1) = "-d" ) Then // Check for command-line parameter to daemonize <<<< === remark here to force
If Not App.Daemonize Then
System.Log( System.LogLevelCritical, "Could not daemonize the Axcys application.")
Return -1
End If
End If <<<< === remark here to force
System.Log( System.LogLevelCritical, "Daemonized the Axcys application.")
#EndIf
#EndIf
This is the init.d code I have been working with - note the comment that ‘Forces’ it to work, but really doesn’t work, in sync with xojo unless remarked as shown above…
#!/bin/bash
# AxcysFacilitySecurityManager daemon
# chkconfig: 345 20 80
# description: AxcysFacilitySecurityManager daemon
# processname: myapp
# /home/pi/Public/axcys/AxcysFacilitySecurityManager/AxcysFacilitySecurityManager &
# /home/pi/Public/axcys/gate/AxcysEmbeddedInterface &
# DAEMON_PATH="/home/wes/Development/projects/myapp"
# DAEMON=myapp
# DAEMONOPTS="-my opts"
# NAME=myapp
# DESC="My daemon description"
# DAEMONOPTS="-d"
# AxcysFacilitySecurityManager
# DAEMON_PATH="/home/pi/Public/axcys/AxcysFacilitySecurityManager/AxcysFacilitySecurityManager"
DAEMON_PATH="/home/pi/Public/axcys/AxcysFacilitySecurityManager/"
DAEMON=AxcysFacilitySecurityManager
DAEMONOPTS=" &"
NAME=AxcysFacilitySecurityManager
DESC="Axcys Startup"
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
case "$1" in
'start')
printf "%-50s" "Starting $NAME..."
cd $DAEMON_PATH
PID=`$DAEMON $DAEMONOPTS > /dev/null 2>&1 & echo $!`
#echo "Saving PID" $PID " to " $PIDFILE
if [ -z $PID ]; then
printf "%s\
" "Fail"
else
echo $PID > $PIDFILE
/home/pi/Public/axcys/AxcysFacilitySecurityManager/AxcysFacilitySecurityManager & <<<< === Use to force
printf "%s\
" "Ok"
fi
;;
'status')
printf "%-50s" "Checking $NAME..."
if [ -f $PIDFILE ]; then
PID=`cat $PIDFILE`
if [ -z "`ps axf | grep ${PID} | grep -v grep`" ]; then
printf "%s\
" "Process dead but pidfile exists"
else
echo "Running"
fi
else
printf "%s\
" "Service not running"
fi
;;
'stop')
printf "%-50s" "Stopping $NAME"
PID=`cat $PIDFILE`
cd $DAEMON_PATH
if [ -f $PIDFILE ]; then
kill -HUP $PID
printf "%s\
" "Ok"
rm -f $PIDFILE
else
printf "%s\
" "pidfile not found"
fi
;;
'restart')
$0 stop
$0 start
;;
*)
echo "Usage: $0 {status|start|stop|restart}"
exit 1
esac
I would really appreciate any feedback/info/help on this! My goal is to use this to both auto start that app, but also to programmatically restart the app too.
Thanks all!
Tim