Hello
Title says it all: In Debian, I need to find a way to launch an application at boot time that doesn't normally run daemonized.
Here's what it looks like in Ubuntu:
Code:
description "My non-daemon app"
start on stopped rc
stop on runlevel [016]
respawn
script
/usr/bin/myapp -document_root /var/www
end script
post-stop exec sleep 3
I tried using an existent init.d script and just adding a trailing "&" on the relevant line in the "start" section, but it doesn't look right: Unlike other daemons, "ps aux" show both the application and the init.d script:
Code:
#! /bin/sh
### BEGIN INIT INFO
# Provides: myapp
# Required-Start: $syslog $time $remote_fs
# Required-Stop: $syslog $time $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: My app
# Description: Debian init script for my app
### END INIT INFO
PATH=/bin:/usr/bin:/sbin:/usr/sbin
DAEMON=/usr/sbin/myapp
PIDFILE=/var/run/myapp.pid
test -x $DAEMON || exit 0
. /lib/lsb/init-functions
case "$1" in
start)
log_daemon_msg "Starting My app" "myapp"
start_daemon -p $PIDFILE $DAEMON &
log_end_msg $?
;;
stop)
log_daemon_msg "Stopping Myapp" "myapp"
killproc -p $PIDFILE $DAEMON
log_end_msg $?
;;
force-reload|restart)
$0 stop
$0 start
;;
status)
status_of_proc -p $PIDFILE $DAEMON atd && exit 0 || exit $?
;;
*)
echo "Usage: /etc/init.d/myapp {start|stop|restart|force-reload|status}"
exit 1
;;
esac
exit 0
Is there a correct way to write an init.d script so that the app is launched with the rest of them?
Thank you.