Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Capistrano-Puma Not Starting Puma Server

Issue Facing

When I run bundle exec cap production puma:start, I get the response that Puma has started successfully:

DEBUG [e4382d1e]    * Pruning Bundler environment
DEBUG [e4382d1e]
DEBUG [e4382d1e]    [2599] Puma starting in cluster mode...
DEBUG [e4382d1e]
DEBUG [e4382d1e]    [2599] * Version 3.0.2 (ruby 2.2.1-p85), codename: Plethora of Penguin Pinatas
DEBUG [e4382d1e]
DEBUG [e4382d1e]    [2599] * Min threads: 0, max threads: 16
DEBUG [e4382d1e]
DEBUG [e4382d1e]    [2599] * Environment: staging
DEBUG [e4382d1e]
DEBUG [e4382d1e]    [2599] * Process workers: 2
DEBUG [e4382d1e]
DEBUG [e4382d1e]    [2599] * Phased restart available
DEBUG [e4382d1e]
DEBUG [e4382d1e]    [2599] * Listening on tcp://0.0.0.0:9294
DEBUG [e4382d1e]
DEBUG [e4382d1e]    [2599] * Daemonizing...

However,

  1. When I run bundle exec cap production puma:status, it says that it cannot find file puma.pid, therefore I think that Puma is not running, and it is not running,
  2. on the server, curl 0.0.0.0:9294 prints curl: (7) Failed to connect to 0.0.0.0 port 9294: Connection refused,
  3. the file puma.pid doesn't exist on the server, and
  4. if I try to start Puma on the server manually, it works fine.

My Setup Information

Here's part of my Gemfile:

gem 'puma'

group :development do
  gem 'spring'
  gem 'capistrano', '~> 3.0'
  gem 'capistrano-rails'
  gem 'capistrano-rvm'
  gem 'capistrano3-puma'
end

Here's the Capfile:

require 'capistrano/setup'
require 'capistrano/deploy'
require 'capistrano/rails'
require 'capistrano/rvm'
require 'capistrano/puma'
require 'capistrano/puma/nginx'

Here's the config/deploy/production.rb:

server 'aws', user: 'my-username', roles: %w{app db web}
set :puma_bind, 'tcp://0.0.0.0:9294'

Any idea on:

  1. What is the cause of issue?
  2. How to fix it?

Thanks.

Update: here's the repo with the Capistrano file. I've left with only Capistrano part (it's a fresh new project): https://github.com/flyfy1/CodeRead/

like image 638
songyy Avatar asked Dec 14 '22 07:12

songyy


2 Answers

I just meet the same problem, and fixed it. When you use cap puma:start, you will see the following sentences in terminal:

 puma:start
      using conf file /your_web_app_path/shared/puma.rb
      01 ~/.rvm/bin/rvm default do bundle exec puma -C /your_web_app_path/shared/puma.rb --daemon

execute bundle exec puma -C /your_web_app_path/shared/puma.rb at your_web_app_path/current/, without the deamon option.

And it will tell you what's wrong with you application. For me, it told me that

 No such file or directory @ rb_io_reopen - /my_web_app_path/shared/log/puma_access.log 
like image 185
dachougui Avatar answered Dec 28 '22 17:12

dachougui


Problem

Capistrano-Puma expects specific shared directories otherwise the server won't start.

These are:
tmp/pids
tmp/sockets log

Solution

Create shared directories in deploy.rb with:

set :linked_dirs, %w(tmp/pids tmp/sockets log)

Verification**

cap puma:start says it is started but doesn't tell you it then fails. Verify with:

cap puma:status

or

ps -ax | grep puma
like image 44
notapatch Avatar answered Dec 28 '22 17:12

notapatch