简体   繁体   中英

Errno::ENOENT: No such file or directory - connect(2) for home/ubuntu/GlucoMeDDC/shared/tmp/sockets/puma.sock

I am deploying my rails app using Capistrano 3, and get this error from the Puma gem:

bundler: failed to load command: puma (/home/ubuntu/GlucoMeDDC/shared/bundle/ruby/2.4.0/bin/puma)
Errno::ENOENT: No such file or directory - connect(2) for home/ubuntu/GlucoMeDDC/shared/tmp/sockets/puma.sock
  /home/ubuntu/GlucoMeDDC/shared/bundle/ruby/2.4.0/gems/puma-3.11.0/lib/puma/binder.rb:367:in `initialize'
  /home/ubuntu/GlucoMeDDC/shared/bundle/ruby/2.4.0/gems/puma-3.11.0/lib/puma/binder.rb:367:in `new'
  /home/ubuntu/GlucoMeDDC/shared/bundle/ruby/2.4.0/gems/puma-3.11.0/lib/puma/binder.rb:367:in `add_unix_listener'
  /home/ubuntu/GlucoMeDDC/shared/bundle/ruby/2.4.0/gems/puma-3.11.0/lib/puma/binder.rb:141:in `block in parse'
  /home/ubuntu/GlucoMeDDC/shared/bundle/ruby/2.4.0/gems/puma-3.11.0/lib/puma/binder.rb:88:in `each'
  /home/ubuntu/GlucoMeDDC/shared/bundle/ruby/2.4.0/gems/puma-3.11.0/lib/puma/binder.rb:88:in `parse'
  /home/ubuntu/GlucoMeDDC/shared/bundle/ruby/2.4.0/gems/puma-3.11.0/lib/puma/runner.rb:144:in `load_and_bind'
  /home/ubuntu/GlucoMeDDC/shared/bundle/ruby/2.4.0/gems/puma-3.11.0/lib/puma/cluster.rb:397:in `run'
  /home/ubuntu/GlucoMeDDC/shared/bundle/ruby/2.4.0/gems/puma-3.11.0/lib/puma/launcher.rb:183:in `run'
  /home/ubuntu/GlucoMeDDC/shared/bundle/ruby/2.4.0/gems/puma-3.11.0/lib/puma/cli.rb:77:in `run'
  /home/ubuntu/GlucoMeDDC/shared/bundle/ruby/2.4.0/gems/puma-3.11.0/bin/puma:10:in `<top (required)>'
  /home/ubuntu/GlucoMeDDC/shared/bundle/ruby/2.4.0/bin/puma:22:in `load'
  /home/ubuntu/GlucoMeDDC/shared/bundle/ruby/2.4.0/bin/puma:22:in `<top (required)>'
puma stderr: Nothing written

I was looking here for an answer but none of it was helpful for me. For example, if I do puma:config it will work, but using the DEFAULT Puma configurations, and not taken from my puma.rb file, even that I added conf pointing to it.

Here is my deploy.rb:

lock '3.10.1'

set :application, 'GlucoMeDDC'
set :repo_url, 'git@github.com:user/GlucoMeDDC.git' # Edit this to match your repository
set :branch, ENV['BRANCH'] if ENV['BRANCH']
set :user, 'ubuntu'
set :deploy_to, '/home/ubuntu/GlucoMeDDC'
set :pty, true
set :linked_files, %w{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
append :rvm_map_bins, 'puma', 'pumactl'
set :rvm_type, :user
set :rvm_ruby_version, 'ruby-2.4.1' # 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, "#{current_path}/config/puma.rb"
set :puma_access_log, "#{shared_path}/log/puma_access.log"
set :puma_error_log, "#{shared_path}/log/puma_error.log"

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 '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

  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

Any tips what else can I do?

I'm pretty sure I've encountered this before and it was a result of missing folders / bad permissions in the path raised in the error. IE the tmp and / or sockets folders missing or inaccessable from:

... home/ubuntu/GlucoMeDDC/shared/tmp/sockets/puma.sock ...

Double check these are being created as expected. It looks as if they should be, although where's shared_path defined - is this definitely correct?

Otherwise check permissions on folders and the file to ensure they're correct. You can run ls -la to check this, and adjust them as appropriate.

Hope there's something in there that helps - keen to hear your feedback.

That issue may caused by wrong puma_bind . It should be:

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

As far as I tried, there is no way to configure puma in both puma.rb and deploy.rb. So I just did all configurations in deploy.rb and it works well. Thank you all for the answers and comments.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM