简体   繁体   中英

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM