Created
October 13, 2013 05:02
-
-
Save lajunta/6958378 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
生成命令,/home/howl/.rvm/bin/bootup_puma: | |
rvm wrapper ruby-1.9.3-p125-perf bootup puma | |
创建Puma的配置文件,/etc/puma/puma.rb: | |
bind 'unix:///tmp/puma.sock' | |
pidfile '/tmp/puma.pid' | |
rackup '/home/howl/one/config.ru' | |
创建服务,/etc/init.d/puma: | |
#!/bin/sh | |
### BEGIN INIT INFO | |
# Provides: puma | |
# Required-Start: $local_fs $remote_fs | |
# Required-Stop: $local_fs $remote_fs | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: S 0 1 6 | |
# Short-Description: puma initscript | |
# Description: puma | |
### END INIT INFO | |
# Original author: Forrest Robertson | |
# Do NOT "set -e" | |
DAEMON=/home/howl/.rvm/bin/bootup_puma # /home/howl/.rvm/gems/ruby-1.9.3-p125-perf/bin/puma | |
SCRIPT_NAME=/etc/init.d/puma | |
CONFIG_FILE=/etc/puma/puma.rb | |
APP_PATH=/home/howl/one | |
PID=/tmp/puma.pid | |
# Exit if the package is not installed | |
[ -x "$DAEMON" ] || exit 0 | |
case "$1" in | |
start) | |
cd $APP_PATH && $DAEMON -C $CONFIG_FILE > $APP_PATH/log/puma.log 2>&1 & | |
;; | |
stop) | |
kill -9 `cat $PID` | |
;; | |
restart) | |
kill -SIGUSR2 `cat $PID` | |
;; | |
*) | |
echo "Usage: $SCRIPT_NAME {start|stop|restart}" >&2 | |
exit 3 | |
;; | |
esac | |
修改nginx.conf: | |
upstream howl_cluster { | |
# server unix:/tmp/thin.howl.sock; | |
server unix://tmp/puma.sock fail_timeout=0; | |
} | |
server { | |
listen 80; | |
server_name imgcdn.shareday.com; | |
root /home/howl/taobao; | |
} | |
server { | |
listen 80; | |
server_name shareday.com www.shareday.com shfeiming.com; | |
root /home/howl/www/public; | |
access_log /home/howl/nginx/access.log; | |
error_log /home/howl/nginx/error.log; | |
location / { | |
proxy_redirect off; | |
proxy_set_header Host $http_host; | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
if (-f $request_filename/index.html) { | |
rewrite (.*) $1/index.html break; | |
} | |
if (-f $request_filename.html) { | |
rewrite (.*) $1.html break; | |
} | |
if (!-f $request_filename) { | |
proxy_pass http://howl_cluster; | |
break; | |
} | |
} | |
} | |
和thin不同,在puma的重启前,必须先停掉nginx,否则puma.sock被占用。 | |
Address already in use - /tmp/puma.sock (Errno::EADDRINUSE) | |
原因在于,进程被杀掉后,puma.sock依旧存在?! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment