Search code examples
ruby-on-railspuma

I am unable to start puma.service using systemd


It has been running well until yesterday. Now, suddenly I cannot get puma running at all. I am currenly using tmux to run puma and run my app. But, it fails when I try to run server using systemctl. Note:- I updated rake and other gems then had to revert back, which gave me error. That I had activated new version of rake, and using older one. So, I decided to install gem 'rubygems-bundler'. Could this have been the cause of the issue?. I have removed this gem now. But, it still doesn't work.

Puma Version: 3.12.0

Here's the puma.service status:

puma.service - Puma HTTP Server
Loaded: loaded (/etc/systemd/system/puma.service; enabled; vendor preset: enabled)
Active: failed (Result: start-limit-hit) since Wed 2020-07-01 12:06:47 UTC; 1s ago
Process: 14640 ExecStart=/home/deploy/.rbenv/shims/puma -C config/puma.rb -p 9100 -e staging (code=exited, status=1/FAILURE)
Main PID: 14640 (code=exited, status=1/FAILURE)

systemd[1]: puma.service: Main process exited, code=exited, status=1/FAILURE
systemd[1]: puma.service: Unit entered failed state.
systemd[1]: puma.service: Failed with result 'exit-code'.
systemd[1]: puma.service: Service hold-off time over, scheduling restart.
systemd[1]: Stopped Puma HTTP Server.
systemd[1]: puma.service: Start request repeated too quickly.
systemd[1]: Failed to start Puma HTTP Server.
systemd[1]: puma.service: Unit entered failed state.
systemd[1]: puma.service: Failed with result 'start-limit-hit'.

My pumar.rb file is:

workers Integer(ENV['WEB_CONCURRENCY'] || 2)
threads_count = Integer(ENV['RAILS_MAX_THREADS'] || 5)
threads threads_count, threads_count

bind "unix:///tmp/production-puma.sock"

preload_app!

rackup      DefaultRackup
port        ENV['PORT']     || 3000
environment ENV['RACK_ENV'] || 'development'

on_worker_boot do
  # Worker specific setup for Rails 4.1+
  ActiveRecord::Base.establish_connection
end

app_path = File.expand_path(File.dirname(__FILE__) + '/../')

stdout_redirect "/#{app_path}/log/puma.stdout.log", "/#{app_path}/log/puma.stderr.log"

Here is puma.service file

[Unit]
Description=Puma HTTP Server
After=network.target

# Uncomment for socket activation (see below)
Requires=puma.socket

[Service]
# Foreground process (do not use --daemon in ExecStart or config.rb)
Type=simple
#Type=forking

# Preferably configure a non-privileged user
User=deploy

# The path to the puma application root
# Also replace the "<WD>" place holders below with this path.
WorkingDirectory=/home/deploy/app

# Helpful for debugging socket activation, etc.
# Environment=PUMA_DEBUG=1

 ExecStart=/home/deploy/.rbenv/shims/puma -C config/puma.rb -p 9100 -e staging

Restart=always

[Install]
WantedBy=multi-user.target

Solution

  • Ok. Fixed the issue. It was indeed caused by rubygems-bundler.

    Uninstall rubygems-bundler with

    gem uninstall rubygems-bundler

    My exact issue was not running following command:

    executable-hooks-uninstaller

    Everything works now. `