How do I restart a Phusion Passenger Standalone?
have to do passenger stop then start or I can still do this by touching tmp/开发者_运维百科restart.txt?
Yes you can restart it by touching tmp/restart.txt.
create a script in /etc/init.d:
$ sudo nano /etc/init.d/YOUR_SERVICE_NAME
Then, Change the parameters according your needs.
#!/bin/sh
### BEGIN INIT INFO
# Provides: <NAME>
# Required-Start: $local_fs $network $named $time $syslog
# Required-Stop: $local_fs $network $named $time $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: <DESCRIPTION>
### END INIT INFO
start() {
echo 'Starting service…' >&2
/bin/bash -l -c 'cd /var/www/myapp/current && passenger start --daemonize -e [staging | production | development ] --ruby path/to/your/bin/ruby'
echo 'Service started' >&2
}
stop() {
echo 'Stopping service…' >&2
passenger stop /var/www/myapp/current
echo 'Service stopped' >&2
}
status() {
passenger status /var/www/myapp/current
}
case "$1" in
start)
start
exit 0
;;
stop)
stop
exit 0
;;
status)
status
exit 0
;;
restart)
stop
start
exit 0
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
esac
Make this file executable:
$ sudo chmod +x /etc/init.d/YOUR_SERVICE_NAME
Then test it:
/etc/init.d/YOUR_SERVICE_NAME start
You can set the to reboot with the system:
$ sudo update-rc.d YOUR_SERVICE_NAME defaults
精彩评论