unicorn 每次重启,都会出现新旧进程并存,旧进程不退出的状况。 如下,42 分启动 unicorn,44 分重启 unicorn,至 49 分 old master 还在运行 如果 stop 的话,需要 stop2 次才能停掉 2 个 master 进程
1000 2075 1 6 23:42 ? 00:00:25 unicorn_rails master (old) -c config/unicorn.rb -E development -D
1000 2096 2075 2 23:43 ? 00:00:09 unicorn_rails worker[0] -c config/unicorn.rb -E development -D
1000 2099 2075 3 23:43 ? 00:00:11 unicorn_rails worker[1] -c config/unicorn.rb -E development -D
1000 2102 2075 3 23:43 ? 00:00:12 unicorn_rails worker[2] -c config/unicorn.rb -E development -D
1000 2105 2075 3 23:43 ? 00:00:12 unicorn_rails worker[3] -c config/unicorn.rb -E development -D
1000 2138 2075 3 23:44 ? 00:00:09 unicorn_rails master -c config/unicorn.rb -E development -D
1000 2150 2138 5 23:44 ? 00:00:16 unicorn_rails worker[0] -c config/unicorn.rb -E development -D
1000 2153 2138 5 23:44 ? 00:00:14 unicorn_rails worker[1] -c config/unicorn.rb -E development -D
1000 2156 2138 5 23:44 ? 00:00:16 unicorn_rails worker[2] -c config/unicorn.rb -E development -D
1000 2159 2138 5 23:44 ? 00:00:17 unicorn_rails worker[3] -c config/unicorn.rb -E development -D
1000 2268 1582 0 23:49 pts/0 00:00:00 grep --color=auto uni
=======
脚本如下:
cat /opt/script/unicorn.sh
#!/bin/sh
case "$1" in
start)
sudo chmod 777 /var/run/
unicorn_rails -c config/unicorn.rb -E development -D
;;
restart)
kill -USR2 $(cat /var/run/unicorn.pid)
;;
stop)
kill $(cat /var/run/unicorn.pid)
;;
*)
echo "Usage:unicorn.sh{start|restart|stop}"
;;
esac