おしっ、unicornの起動スクリプト登録 $ sudo vi /etc/init.d/unicorn ================================================ #!/bin/sh # chkconfig: 345 90 20 # description: Rails application sample RAILS_ENV=production SERVICE=myapp1 USER=vagrant RAILS_ROOT_DIR="/home/vagrant/railsapp/myapp1/" PID=${RAILS_ROOT_DIR}/tmp/pids/unicorn.pid UNICORN_CONF=${RAILS_ROOT_DIR}/config/unicorn.rb UNICORN_ALIVE=`ps aux|grep '${UNICORN_CONF}'|grep -v grep|wc -l` start() { if [ $UNICORN_ALIVE = 0 ]; then rm -f $PID fi if [ -e ${PID} ]; then echo "${SERVICE} already started" exit 1 fi echo "start ${SERVICE}" sudo su -l ${USER} -c "cd ${RAILS_ROOT_DIR} && bundle exec unicorn_rails -c ${UNICORN_CONF} -D -p 3000" } stop() { if [ ! -e ${PID} ]; then echo "${SERVICE} not started" exit 1 fi echo "stop ${SERVICE}" kill -QUIT `cat ${PID}` } force_stop() { if [ ! -e ${PID} ]; then echo "${SERVICE} not started" exit 1 fi echo "stop ${SERVICE}" kill -INT `cat ${PID}` } reload() { if [ ! -e ${PID} ]; then echo "${SERVICE} not started" start exit 0 fi echo "reload ${SERVICE}" kill -USR2 `cat ${PID}` } restart() { if [ -e ${PID} ]; then stop sleep 3 fi start } case "$1" in start) start ;; stop) stop ;; force-stop) force_stop ;; reload) reload ;; restart) restart ;; *) echo "Syntax Error: release [start|stop|force-stop|reload|restart]" ;; esac ================================================ $ sudo chmod 755 /etc/init.d/unicorn $ sudo chown root unicorn $ sudo chgrp root unicorn $ sudo /etc/init.d/unicorn stop $ sudo apt-get install sysv-rc-conf $ sudo sysv-rc-conf unicorn on $ sudo sysv-rc-conf $ sudo reboot

おしっ、unicornの起動スクリプト登録 $ sudo vi /etc/init.d/unicorn ==============================================...
=======================================
おしっ、unicornの起動スクリプト登録


$ sudo vi /etc/init.d/unicorn
================================================
#!/bin/sh
# chkconfig: 345 90 20
# description: Rails application sample
RAILS_ENV=production
SERVICE=myapp1
USER=vagrant

RAILS_ROOT_DIR="/home/vagrant/railsapp/myapp1/"

PID=${RAILS_ROOT_DIR}/tmp/pids/unicorn.pid
UNICORN_CONF=${RAILS_ROOT_DIR}/config/unicorn.rb

UNICORN_ALIVE=`ps aux|grep '${UNICORN_CONF}'|grep -v grep|wc -l`

start()
{
if [ $UNICORN_ALIVE = 0 ]; then
rm -f $PID
fi
if [ -e ${PID} ]; then
echo "${SERVICE} already started"
exit 1
fi
echo "start ${SERVICE}"
sudo su -l ${USER} -c "cd ${RAILS_ROOT_DIR} && bundle exec unicorn_rails -c ${UNICORN_CONF} -D -p 3000"
}

stop()
{
if [ ! -e ${PID} ]; then
echo "${SERVICE} not started"
exit 1
fi
echo "stop ${SERVICE}"
kill -QUIT `cat ${PID}`
}

force_stop()
{
if [ ! -e ${PID} ]; then
echo "${SERVICE} not started"
exit 1
fi
echo "stop ${SERVICE}"
kill -INT `cat ${PID}`
}

reload()
{
if [ ! -e ${PID} ]; then
echo "${SERVICE} not started"
start
exit 0
fi
echo "reload ${SERVICE}"
kill -USR2 `cat ${PID}`
}

restart()
{
if [ -e ${PID} ]; then
stop
sleep 3
fi
start
}

case "$1" in
start)
start
;;
stop)
stop
;;
force-stop)
force_stop
;;
reload)
reload
;;
restart)
restart
;;
*)
echo "Syntax Error: release [start|stop|force-stop|reload|restart]"
;;
esac
================================================

$ sudo chmod 755 /etc/init.d/unicorn
$ sudo chown root unicorn
$ sudo chgrp root unicorn
$ sudo /etc/init.d/unicorn stop

$ sudo apt-get install sysv-rc-conf
$ sudo sysv-rc-conf unicorn on
$ sudo sysv-rc-conf

$ sudo reboot

http://ift.tt/1abnmbU
May 12, 2016 at 03:40PM

コメント

このブログの人気の投稿

投稿時間:2021-06-17 05:05:34 RSSフィード2021-06-17 05:00 分まとめ(1274件)

投稿時間:2021-06-20 02:06:12 RSSフィード2021-06-20 02:00 分まとめ(3871件)

投稿時間:2020-12-01 09:41:49 RSSフィード2020-12-01 09:00 分まとめ(69件)