puma.sock missing in ec2 server after capistrano deployment

寵の児 提交于 2020-01-04 02:12:09

问题


I am getting the following error in the nginx error logs after deploying production a ruby on rails project through capistrano to an instance on ec2. The amazon public host shows a 502 Bad Gateway nginx/1.10.0 (Ubuntu). I followed the tutorial from https://www.sitepoint.com/deploy-your-rails-app-to-aws/ It seems the puma.sock is not being created when I run cap production deploy..

2017/06/28 01:09:57 [crit] 12802#12802: *1 connect() to unix:/home/deploy/app_name/shared/tmp/sockets/puma.sock failed (2: No such file or directory) while connecting to upstream, client: 173.198.30.2, server: localhost, request: "GET / HTTP/1.1", upstream: "http://unix:/home/deploy/app_name/shared/tmp/sockets/puma.sock:/", host: "host"

The following is in my deploy.rb

set :application, 'app_name'
set :repo_url, 'git@github.com:github_account/app_name.git' # Edit this to match your repository
set :branch, :master
set :deploy_to, '/home/deploy/app_name'
set :pty, true
set :linked_files, %w{config/database.yml config/application.yml}
set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system public/uploads}
set :keep_releases, 5
set :rvm_type, :user
set :rvm_ruby_version, 'ruby-2.3.3' # Edit this if you are using MRI Ruby

set :puma_rackup, -> { File.join(current_path, 'config.ru') }
set :puma_state, "#{shared_path}/tmp/pids/puma.state"
set :puma_pid, "#{shared_path}/tmp/pids/puma.pid"
set :puma_bind, "unix://#{shared_path}/tmp/sockets/puma.sock"    #accept array for multi-bind
set :puma_conf, "#{shared_path}/puma.rb"
set :puma_access_log, "#{shared_path}/log/puma_error.log"
set :puma_error_log, "#{shared_path}/log/puma_access.log"
set :puma_role, :app
set :puma_env, fetch(:rack_env, fetch(:rails_env, 'production'))
set :puma_threads, [0, 8]
set :puma_workers, 0
set :puma_worker_timeout, nil
set :puma_init_active_record, true
set :puma_preload_app, false

Please help! Thanks in advance!


回答1:


I was getting this same error when working on EC2 instance installing Rails with Capistrano and nginx

if you are getting 502 error Add install_plugin Capistrano::Puma into your Capfile after require 'capistrano/puma'.




回答2:


Try to use the follow line

set :puma_bind,       "unix://#{shared_path}/tmp/sockets/#{fetch(:application)}-puma.sock"

Instead of

set :puma_bind, "unix://#{shared_path}/tmp/sockets/puma.sock"



回答3:


I didn't know the newer version of Capistrano breaks the whole environment. I had the lock for capistrano at '3.8.2' in the deploy.rb. Switching it to 3.5.0 fixed the problem. -_-




回答4:


I don't know but I had the same problem with the newest version of Capistrano Puma Gem but... Try the next two things:

  1. Set I guess the deploy user inside the deploy.rb file.
set :user, 'deploy'
  1. Push this code to your github project and after that, run the command 'cap production deploy' twice. I don't understand why but it works for me. I know, it really sounds stupid as hell but was the solution I found.


来源:https://stackoverflow.com/questions/44810338/puma-sock-missing-in-ec2-server-after-capistrano-deployment

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!