Add Rails program to/ETC/INIT.D boot automatically

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.