Skip to content

Instantly share code, notes, and snippets.

@madwork
Last active July 27, 2016 05:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save madwork/7680478 to your computer and use it in GitHub Desktop.
Save madwork/7680478 to your computer and use it in GitHub Desktop.
Upstart with Puma and chruby for a single app (single mode).
after "deploy:restart", "puma:restart"
namespace :puma do
task :restart, roles: :app do
run "cd #{current_path} && #{bundle_cmd} exec pumactl -S #{shared_path}/pids/puma.state restart"
end
end
upstream app_server {
server unix:///srv/deploy/app/shared/sockets/puma.sock fail_timeout=0;
}
server {
listen 80;
server_name _;
access_log /var/log/nginx/app-access.log combined;
keepalive_timeout 5;
root /srv/deploy/app/current/public;
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://app_server;
}
location ~ ^/assets/ {
root /srv/deploy/app/current/public;
gzip_static on;
expires 1y;
add_header Cache-Control "public";
add_header ETag "";
access_log off;
}
error_page 500 502 503 504 /500.html;
location = /500.html {
root /srv/deploy/app/current/public;
}
}
directory '/srv/deploy/app/current'
rackup '/srv/deploy/app/current/config.ru'
environment 'production'
daemonize false
pidfile '/srv/deploy/app/shared/pids/puma.pid'
state_path '/srv/deploy/app/shared/pids/puma.state'
stdout_redirect '/srv/deploy/app/shared/log/puma-stdout.log', '/srv/deploy/app/shared/log/puma-stderr.log'
threads 0, 32
workers 0
bind 'unix:///srv/deploy/app/shared/sockets/puma.sock'
description "Puma Process Monitoring"
author "Vincent Durand <vincent.durand@madwork.org>"
start on runlevel [12]
stop on shutdown
respawn
respawn limit 5 15
setuid deploy
setgid deploy
script
exec /bin/bash << EOT
export HOME=/srv/deploy
source /usr/local/share/chruby/chruby.sh
source /usr/local/share/chruby/auto.sh
cd /srv/deploy/app/current && exec bundle exec puma -C config/puma/production.rb
EOT
end script
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment