In order to stop and start applications automatically on Debian I created a script based on the skeleton in /etc/init.d and then ran the update-rc.d command on it:
update-rc.d test_server1 start 99 3 . stop 01 0 6
This created the relevant links in /etc/rc3.d to start it and in /etc/rc0.d and rc6.d to stop it. The problem seems to be that at system boot time it doesn't seem to run the script but at system shutdown it does. You can run the script manually but need to provide a parameter (start/stop/restart/status) so I know it is working and as can be seen, the shutdown is fine. I'm just wondering as to why the start is not being picked up.
The only differences between the stop and start is that start uses the start-stop-daemon, i.e.
start-stop-daemon --start --pidfile $PIDFILE --startas $DAEMONSTA $NAME --test > /dev/null \
|| return 1
start-stop-daemon --start --pidfile $PIDFILE --startas $DAEMONSTA $NAME -- \
|| return 2
whereas stopping it uses commands sent to the server as start-stop-daemon justs gets the pid and then kills the process but I want it to stop cleanly, i.e.
$DAEMONSTO $NAME -user adminuser -password password
The restart just calls the above 2 steps and works fine. Just wondering if I missed something somewhere...TIA.
update-rc.d test_server1 start 99 3 . stop 01 0 6
This created the relevant links in /etc/rc3.d to start it and in /etc/rc0.d and rc6.d to stop it. The problem seems to be that at system boot time it doesn't seem to run the script but at system shutdown it does. You can run the script manually but need to provide a parameter (start/stop/restart/status) so I know it is working and as can be seen, the shutdown is fine. I'm just wondering as to why the start is not being picked up.
The only differences between the stop and start is that start uses the start-stop-daemon, i.e.
start-stop-daemon --start --pidfile $PIDFILE --startas $DAEMONSTA $NAME --test > /dev/null \
|| return 1
start-stop-daemon --start --pidfile $PIDFILE --startas $DAEMONSTA $NAME -- \
|| return 2
whereas stopping it uses commands sent to the server as start-stop-daemon justs gets the pid and then kills the process but I want it to stop cleanly, i.e.
$DAEMONSTO $NAME -user adminuser -password password
The restart just calls the above 2 steps and works fine. Just wondering if I missed something somewhere...TIA.

Comment