-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b21135a
commit cd6858b
Showing
4 changed files
with
114 additions
and
12 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,84 @@ | ||
set :application, "crawler_rebuild" | ||
set :repo_url, "[email protected]:ParzivalRealm/crawler_rebuild.git" | ||
# Change these | ||
server '64.227.97.163', port: 80, roles: [:web, :app, :db], primary: true | ||
|
||
# Deploy to the user's home directory | ||
set :deploy_to, "/home/deploy/#{fetch :application}" | ||
set :repo_url, '[email protected]:ParzivalRealm/crawler_rebuild.git' | ||
set :application, 'crawler_rebuild' | ||
set :user, 'deploy' | ||
set :puma_threads, [4, 16] | ||
set :puma_workers, 0 | ||
|
||
append :linked_dirs, 'log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', '.bundle', 'public/system', 'public/uploads' | ||
# Don't change these unless you know what you're doing | ||
set :pty, true | ||
set :use_sudo, false | ||
set :stage, :production | ||
set :deploy_via, :remote_cache | ||
set :deploy_to, "/home/#{fetch(:user)}/apps/#{fetch(:application)}" | ||
set :puma_bind, "unix://#{shared_path}/tmp/sockets/#{fetch(:application)}-puma.sock" | ||
set :puma_state, "#{shared_path}/tmp/pids/puma.state" | ||
set :puma_pid, "#{shared_path}/tmp/pids/puma.pid" | ||
set :puma_access_log, "#{release_path}/log/puma.error.log" | ||
set :puma_error_log, "#{release_path}/log/puma.access.log" | ||
set :ssh_options, { forward_agent: true, user: fetch(:user), keys: %w(~/.ssh/id_rsa.pub) } | ||
set :puma_preload_app, true | ||
set :puma_worker_timeout, nil | ||
set :puma_init_active_record, true # Change to false when not using ActiveRecord | ||
|
||
# Only keep the last 5 releases to save disk space | ||
set :keep_releases, 5 | ||
## Defaults: | ||
# set :scm, :git | ||
# set :branch, :master | ||
# set :format, :pretty | ||
# set :log_level, :debug | ||
# set :keep_releases, 5 | ||
|
||
# Optionally, you can symlink your database.yml and/or secrets.yml file from the shared directory during deploy | ||
# This is useful if you don't want to use ENV variables | ||
# append :linked_files, 'config/database.yml', 'config/secrets.yml' | ||
## Linked Files & Directories (Default None): | ||
# set :linked_files, %w{config/database.yml} | ||
# set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system} | ||
|
||
namespace :puma do | ||
desc 'Create Directories for Puma Pids and Socket' | ||
task :make_dirs do | ||
on roles(:app) do | ||
execute "mkdir #{shared_path}/tmp/sockets -p" | ||
execute "mkdir #{shared_path}/tmp/pids -p" | ||
end | ||
end | ||
|
||
before :start, :make_dirs | ||
end | ||
|
||
namespace :deploy do | ||
desc "Make sure local git is in sync with remote." | ||
task :check_revision do | ||
on roles(:app) do | ||
unless `git rev-parse HEAD` == `git rev-parse origin/master` | ||
puts "WARNING: HEAD is not the same as origin/master" | ||
puts "Run `git push` to sync changes." | ||
exit | ||
end | ||
end | ||
end | ||
|
||
desc 'Initial Deploy' | ||
task :initial do | ||
on roles(:app) do | ||
before 'deploy:restart', 'puma:start' | ||
invoke 'deploy' | ||
end | ||
end | ||
|
||
desc 'Restart application' | ||
task :restart do | ||
on roles(:app), in: :sequence, wait: 5 do | ||
invoke 'puma:restart' | ||
end | ||
end | ||
|
||
before :starting, :check_revision | ||
after :finishing, :compile_assets | ||
after :finishing, :cleanup | ||
after :finishing, :restart | ||
end | ||
|
||
# ps aux | grep puma # Get puma pid | ||
# kill -s SIGUSR2 pid # Restart puma | ||
# kill -s SIGTERM pid # Stop puma |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
upstream puma { | ||
server unix:///home/deploy/apps/crawler_rebuild/shared/tmp/sockets/crawler_rebuild-puma.sock; | ||
} | ||
|
||
server { | ||
listen 80 default_server deferred; | ||
# server_name example.com; | ||
|
||
root /home/deploy/apps/crawler_rebuild/current/public; | ||
access_log /home/deploy/apps/crawler_rebuild/current/log/nginx.access.log; | ||
error_log /home/deploy/apps/crawler_rebuild/current/log/nginx.error.log info; | ||
|
||
location ^~ /assets/ { | ||
gzip_static on; | ||
expires max; | ||
add_header Cache-Control public; | ||
} | ||
|
||
try_files $uri/index.html $uri @puma; | ||
location @puma { | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_set_header Host $http_host; | ||
proxy_redirect off; | ||
|
||
proxy_pass http://puma; | ||
} | ||
|
||
error_page 500 502 503 504 /500.html; | ||
client_max_body_size 10M; | ||
keepalive_timeout 10; | ||
} |