Skip to content

Instantly share code, notes, and snippets.

@ujifgc
Last active December 20, 2015 23:18
Show Gist options
  • Save ujifgc/6211206 to your computer and use it in GitHub Desktop.
Save ujifgc/6211206 to your computer and use it in GitHub Desktop.
Scripts to serve rack apps with puma
upstream swift {
server unix:/home/ujif/swift/tmp/puma.sock;
}
server {
server_name s.ujif.name;
root /home/ujif/swift/public;
location / {
try_files $uri @swift;
}
location @swift {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://swift;
}
access_log /home/ujif/swift/log/nginx-access.log combined buffer=4;
error_log /home/ujif/swift/log/nginx-error.log;
}
#!/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: 0 1 6
# Short-Description: puma initscript
# Description: puma
### END INIT INFO
DAEMON=/usr/local/rvm/bin/pumactl_pumactl
SCRIPT_NAME=/etc/init.d/puma
CONFIG_PATH=/etc/puma
# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0
case "$1" in
start)
for file in $CONFIG_PATH/*.rb
do
su ujif -c "$DAEMON --config $file start"
done
;;
stop)
for file in $CONFIG_PATH/*.rb
do
su ujif -c "$DAEMON --config $file stop"
done
;;
restart)
for file in $CONFIG_PATH/*.rb
do
su ujif -c "$DAEMON --config $file stop"
sleep 1
su ujif -c "$DAEMON --config $file start"
done
;;
*)
echo "Usage: $SCRIPT_NAME {start|stop|restart}" >&2
exit 3
;;
esac
:
#!/usr/bin/env puma
PUMA_ROOT = '/home/ujif/swift'
PUMA_ENV = 'development'
#PUMA_ENV = 'production'
environment PUMA_ENV
daemonize
directory PUMA_ROOT
pidfile PUMA_ROOT + '/tmp/puma.pid'
#state_path PUMA_ROOT + '/tmp/puma.state'
stdout_redirect PUMA_ROOT + '/log/puma-stdout.log',
PUMA_ROOT + '/log/puma-stderr.log', true
quiet if PUMA_ENV == 'production'
threads 1, 16
#workers 4
#bind "tcp://0.0.0.0:9292"
#bind "unix:///var/run/puma.sock"
bind "unix://#{PUMA_ROOT}/tmp/puma.sock?umask=0111"
# bind "ssl://127.0.0.1:9292?key=path_to_key&cert=path_to_cert"
# activate_control_app "unix://#{PUMA_ROOT}/tmp/pumactl.sock", { no_token: true }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment