PROBLEMA: Ao executar o comando de deploy do capistrano ($ bundle exec cap production deploy
) é apresentado o seguinte erro:
Permission denied (publickey).
DEBUG[4a3de544] fatal: Could not read from remote repository.''
SOLUÇÃO:
$ eval "$(ssh-agent -s)"
$ ssh-add ~/.ssh/id_rsa
_PROBLEMA: Após realizar o DEPLOY a aplicação não "rodava". Aprensentando erro 502 no navegador e no log do ngnix os seguinte erros:
24: Too many open files
Ou/e
readv() failed (104: Connection reset by peer) while reading upstream
SOLUÇÃO: Alterações nos arquivos:
aplicacao/config/unicorn/production.rb
root = "/var/www/NOME_APLICACAO/current"
working_directory root
pid "#{root}/tmp/pids/unicorn.pid"
stderr_path "#{root}/log/unicorn.log"
stdout_path "#{root}/log/unicorn.log"
timeout 30
preload_app true
listen '/tmp/unicorn.NOME_APLICACAO.sock', backlog: 64
before_fork do |server, worker|
Signal.trap 'TERM' do
puts 'Unicorn master intercepting TERM and sending myself QUIT instead'
Process.kill 'QUIT', Process.pid
end
defined?(ActiveRecord::Base) and
ActiveRecord::Base.connection.disconnect!
end
after_fork do |server, worker|
Signal.trap 'TERM' do
puts 'Unicorn worker intercepting TERM and doing nothing. Wait for master to send QUIT'
end
defined?(ActiveRecord::Base) and
ActiveRecord::Base.establish_connection
end
# Force the bundler gemfile environment variable to
# reference the capistrano "current" symlink
before_exec do |_|
ENV['BUNDLE_GEMFILE'] = File.join(root, 'Gemfile')
end
/etc/nginx/sites-enabled/default
upstream unicorn {
server unix:/tmp/unicorn.NOME_APLICACAO.sock fail_timeout=0;
}
server {
listen 80 default deferred;
# server_name DOMINIO_OU_IP;
root /var/www/NOME_APLICACAO/current/public;
location ^~ /assets/ {
gzip_static on;
expires max;
add_header Cache-Control public;
}
location ~ ^/(robots.txt|sitemap.xml.gz)/ {
root /var/www/NOME_APLICACAO/current/public;
}
try_files $uri/index.html $uri @unicorn;
location @unicorn {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://unicorn;
}
error_page 500 502 503 504 /500.html;
client_max_body_size 4G;
keepalive_timeout 10;
}