I am trying to deploy a rails 7
application on aws-lightsail
unbuntu 20.04
instance using capistrano3
gem. After deployment, I see 502 bad gateway
nginx page in browser. When I check puma_error.log
, log says that connection to puma.sock was refused
.
I ran ps ax | grep puma
to check if puma is running but nothing shows up. I restarted puma by cap production puma:restart
and it shows puma has successfully started and daemaonized.
shoaib:report shoaib$ cap production puma:restart
00:00 puma:start
using conf file /home/ubuntu/app_name/shared/puma.rb
01 $HOME/.rbenv/bin/rbenv exec bundle exec puma -C /home/ubuntu/app_name/shared/puma.rb --daemon
01 * Pruning Bundler environment
01
01 [DEPRECATED] `Bundler.with_clean_env` has been deprecated in favor of `Bundler.with_unbundled_env`. If you instead want the environment before bundl…
01
01 [214552] Puma starting in cluster mode...
01
01 [214552] * Version 3.12.6 (ruby 3.1.2-p20), codename: Llamas in Pajamas
01
01 [214552] * Min threads: 0, max threads: 8
01
01 [214552] * Environment: production
01
01 [214552] * Process workers: 2
01
01 [214552] * Phased restart available
01
01 [214552] * Listening on unix:///home/ubuntu/app_name/shared/tmp/sockets/puma.sock
01
01 [214552] * Daemonizing...
01
✔ 01 ubuntu@3.12.163.170 1.922s
But when i run cap production puma:status
, it says puma not running.
shoaib:report shoaib$ cap production puma:status
00:00 puma:status
WARN Puma not running
In addition, no puma.pid
file is being created in /tmp/pids/
directory on server. Can someone please point me in the right direction as I already have spent many hours on it.
Thanks!
I solved this issue by switching to rvm
from rbenv
on my server instance. The problem was rbenv
not identifying application's current
directory as a rails
application thus not invoking rails s
command on it. When I ran rails s -e production
in app's current directory, only the template of rails command was printed in response.
So switching to rvm
solved the issue for me. I am still clueless on rbenv
behaviour that caused this issue.