Capistrano recipe
This commit is contained in:
10
config/deploy/shared/database.yml.erb
Normal file
10
config/deploy/shared/database.yml.erb
Normal file
@@ -0,0 +1,10 @@
|
||||
<%= fetch(:rails_env) %>:
|
||||
adapter: postgresql
|
||||
timeout: 5000
|
||||
encoding: unicode
|
||||
reconnect: false
|
||||
database: <%= "#{fetch(:application)}" %>
|
||||
pool: 5
|
||||
username:
|
||||
password:
|
||||
host: <%= fetch(:db_server) %>
|
||||
11
config/deploy/shared/log_rotation.erb
Executable file
11
config/deploy/shared/log_rotation.erb
Executable file
@@ -0,0 +1,11 @@
|
||||
<%= fetch(:deploy_to) %>/shared/log/*.log {
|
||||
daily
|
||||
missingok
|
||||
rotate 52
|
||||
compress
|
||||
delaycompress
|
||||
notifempty
|
||||
sharedscripts
|
||||
endscript
|
||||
copytruncate
|
||||
}
|
||||
4
config/deploy/shared/secrets.yml.erb
Normal file
4
config/deploy/shared/secrets.yml.erb
Normal file
@@ -0,0 +1,4 @@
|
||||
<%= fetch(:rails_env) %>:
|
||||
recaptcha_public_key: <%= ENV["MADRID_RECAPTCHA_PUBLIC_KEY"] %>
|
||||
recaptcha_private_key: <%= ENV["MADRID_RECAPTCHA_PRIVATE_KEY"] %>
|
||||
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
|
||||
2
config/deploy/shared/sidekiq.yml.erb
Normal file
2
config/deploy/shared/sidekiq.yml.erb
Normal file
@@ -0,0 +1,2 @@
|
||||
<%= fetch(:rails_env) %>:
|
||||
:concurrency: <%= fetch(:sidekiq_concurrency, 5) %>
|
||||
42
config/deploy/shared/unicorn.rb.erb
Executable file
42
config/deploy/shared/unicorn.rb.erb
Executable file
@@ -0,0 +1,42 @@
|
||||
root = "<%= current_path %>"
|
||||
working_directory root
|
||||
pid "#{root}/tmp/pids/unicorn.pid"
|
||||
stderr_path "#{root}/log/unicorn.log"
|
||||
stdout_path "#{root}/log/unicorn.log"
|
||||
|
||||
listen 5000
|
||||
#listen "/tmp/unicorn.<%= fetch(:application) %>.sock"
|
||||
worker_processes 4
|
||||
timeout 40
|
||||
preload_app true
|
||||
|
||||
# Force unicorn to look at the Gemfile in the current_path
|
||||
# otherwise once we've first started a master process, it
|
||||
# will always point to the first one it started.
|
||||
before_exec do |server|
|
||||
ENV['BUNDLE_GEMFILE'] = "<%= current_path %>/Gemfile"
|
||||
end
|
||||
|
||||
before_fork do |server, worker|
|
||||
defined?(ActiveRecord::Base) and
|
||||
ActiveRecord::Base.connection.disconnect!
|
||||
# Quit the old unicorn process
|
||||
old_pid = "#{server.config[:pid]}.oldbin"
|
||||
if File.exists?(old_pid) && server.pid != old_pid
|
||||
puts "We've got an old pid and server pid is not the old pid"
|
||||
begin
|
||||
Process.kill("QUIT", File.read(old_pid).to_i)
|
||||
puts "killing master process (good thing tm)"
|
||||
rescue Errno::ENOENT, Errno::ESRCH
|
||||
puts "unicorn master already killed"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
after_fork do |server, worker|
|
||||
port = 5000 + worker.nr
|
||||
child_pid = server.config[:pid].sub('.pid', ".#{port}.pid")
|
||||
system("echo #{Process.pid} > #{child_pid}")
|
||||
defined?(ActiveRecord::Base) and
|
||||
ActiveRecord::Base.establish_connection
|
||||
end
|
||||
Reference in New Issue
Block a user