Last active
August 29, 2015 14:06
-
-
Save vdv/66f12ec44f49a730ff9f to your computer and use it in GitHub Desktop.
Ubuntu 12.04 Rails run scripts
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
upstream rails_app_upstream { | |
server unix:/home/deployer/projects/rails_app/shared/tmp/sockets/unicorn.socket fail_timeout=0; | |
} | |
server { | |
#listen 80; ## listen for ipv4; this line is default and implied | |
#listen [::]:80 default ipv6only=on; ## listen for ipv6 | |
server_name localhost my_server.ru; | |
root /home/deployer/projects/rails_app/current/public; | |
index index.html index.htm; | |
access_log /home/deployer/projects/rails_app/shared/log/nginx-access.log; | |
error_log /home/deployer/projects/rails_app/shared/log/nginx-error.log; | |
client_max_body_size 10m; | |
client_body_buffer_size 128k; | |
location / { | |
try_files $uri/index.html $uri.html $uri @rails_app; | |
} | |
location @rails_app{ | |
proxy_pass http://rails_app_upstream; | |
proxy_redirect off; | |
proxy_set_header Host $host; | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_connect_timeout 90; | |
proxy_send_timeout 90; | |
proxy_read_timeout 90; | |
proxy_buffer_size 4k; | |
proxy_buffers 4 32k; | |
proxy_busy_buffers_size 64k; | |
proxy_temp_file_write_size 64k; | |
} | |
#location ~ ^/(images|javascripts|stylesheets|system|assets|ckeditor_assets)/ { | |
location ~* ".*?\.(ico|css|js|gif|jpg|jpeg|png|doc|pdf)(\?[0-9]*)?$" { | |
expires 24h; | |
#expires max; | |
proxy_cache_valid 200 302 60m; | |
proxy_cache_valid 404 1m; | |
break; | |
} | |
} |
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
description "RailsApp DelatedJob" | |
start on runlevel [2] | |
stop on runlevel [016] | |
console log | |
setuid deployer | |
script | |
chdir /home/deployer/projects/rails_app/current | |
RAILS_ENV=production /home/deployer/.rbenv/shims/bundle exec /home/deployer/projects/rails_app/current/script/delayed_job start | |
end script |
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
description "RailsApp Application" | |
start on runlevel [2345] | |
stop on runlevel [016] | |
console log | |
setuid deployer | |
script | |
cd /home/deployer/projects/rails_app/current && /home/deployer/.rbenv/shims/bundle exec unicorn_rails -c ./config/unicorn.conf.rb -E production | |
end script | |
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
description "RailsApp Application" | |
start on runlevel [2345] | |
stop on runlevel [016] | |
console log | |
setuid deployer | |
chdir /home/deployer/projects/rails_app/current | |
exec /home/deployer/projects/rails_app/current/rvm_wrapper unicorn_rails -c /home/deployer/projects/rails_app/current/config/unicorn/unicorn.rb -E production | |
respawn |
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
#!/usr/bin/env bash | |
if [[ -s "/home/deployer/.rvm/environments/ruby-2.0.0-p247" ]] | |
then | |
source "/home/deployer/.rvm/environments/ruby-2.0.0-p247" | |
exec bundle exec "$@" | |
else | |
echo "ERROR: Missing RVM environment file: '/home/deployer/.rvm/environments/ruby-2.0.0-p247'" >&2 | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment