Last active
December 21, 2015 01:48
-
-
Save ryantownsend/6230000 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
| namespace :foreman do | |
| desc "Export the Procfile to Ubuntu's upstart scripts" | |
| task :export do | |
| options = { | |
| :app => fetch(:application), | |
| :log => shared_path.join("log"), | |
| :user => fetch(:user) | |
| } | |
| roles(:app).each do |server| | |
| on(server) do | |
| option_string = options.map { |k,v| "--#{k}=#{v}" }.join(" ") | |
| execute "cd #{release_path} && sudo `which bundle` exec foreman export upstart /etc/init #{option_string}" | |
| end | |
| end | |
| end | |
| desc "Start the application" | |
| task :start do | |
| on roles(:app) do | |
| execute "sudo start #{fetch(:application)}" | |
| end | |
| end | |
| desc "Stop the application" | |
| task :stop do | |
| on roles(:app) do | |
| execute "sudo stop #{fetch(:application)} 2>/dev/null; echo ''" | |
| end | |
| end | |
| desc "Restart the application" | |
| task :restart do | |
| on roles(:app) do | |
| execute "sudo restart #{fetch(:application)}" | |
| end | |
| end | |
| after "deploy:bundle", "foreman:export" | |
| end |
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
| # ... | |
| http { | |
| upstream appserver { | |
| server unix:///path/to/shared/tmp/sockets/puma.sock; | |
| } | |
| server { | |
| # ssl only | |
| listen 443 ssl default deferred; | |
| # set the domain | |
| server_name DOMAIN_NAME; | |
| # ... | |
| # location of our static files | |
| root /path/to/current/public; | |
| # attempt to find the file, if not, serve via puma | |
| try_files $uri @app; | |
| location @app { | |
| # if the maintenance page exists, throw a 503 error | |
| if (-f $document_root/system/maintenance.html) { | |
| return 503; | |
| break; | |
| } | |
| proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
| proxy_set_header X-Forwarded-Proto $scheme; | |
| proxy_set_header Host $http_host; | |
| proxy_redirect off; | |
| proxy_pass http://appserver; | |
| } | |
| } | |
| } |
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
| web: bundle exec puma -t 2:8 -C /path/to/current/config/puma.rb -b unix:///path/to/shared/tmp/sockets/puma.sock |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment