必须做乘客然后开始 或者我仍然可以通过触摸tmp / restart.txt来执行此操作?
答案 0 :(得分:13)
是的,您可以通过触摸tmp / restart.txt重新启动它。
答案 1 :(得分:0)
在 /etc/init.d 中创建一个脚本:
$ sudo nano /etc/init.d/YOUR_SERVICE_NAME
然后,根据需要更改参数。
#!/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
使这个文件可执行:
$ sudo chmod +x /etc/init.d/YOUR_SERVICE_NAME
然后测试一下:
/etc/init.d/YOUR_SERVICE_NAME start
您可以设置随系统重启:
$ sudo update-rc.d YOUR_SERVICE_NAME defaults