Please make the corresponding modification according to your own actual situation, the file storage location is/etc/init.d/<name>:
| The code is as follows |
Copy Code |
| #! /bin/sh
#http://www.111cn.net
### BEGIN INIT INFO # Provides:unicorn # Required-start: $local _fs $remote _fs $network $syslog # required-stop: $local _fs $remote _fs $network $syslog # Default-start:2 3 4 5 # default-stop:0 1 6 # Short-description:starts the Unicorn Web server # Description:starts Unicorn ### End INIT INFO
Path=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin Daemon=/usr/local/bin/unicorn_rails daemon_opts= "-c/home/wwwroot/matz.cn/config/unicorn.rb-e production-d" Name=unicorn_rails Desc=unicorn_rails Pid=/home/wwwroot/matz.cn/tmp/pids/unicorn.pid
Case "$" in Start Echo-n "Starting $DESC:" $DAEMON $DAEMON _opts echo "$NAME." ;; Stop Echo-n "Stopping $DESC:" Kill-quit ' Cat $PID ' echo "$NAME." ;; Restart) Echo-n "Restarting $DESC:" Kill-quit ' Cat $PID ' Sleep 1 $DAEMON $DAEMON _opts echo "$NAME." ;; Reload Echo-n "Reloading $DESC configuration:" Kill-hup ' Cat $PID ' echo "$NAME." ;; *) echo "Usage: $NAME {start|stop|restart|reload}" >&2 Exit 1 ;; Esac
Exit 0 |
To add a self-boot by using the Chkconfig command:
| The code is as follows |
Copy Code |
Chkconfig--add <name> Chkconfig <name> on |
At this point, the Rails program is started with the system after the system is restarted.