Daniel D
Daniel D

Reputation: 3677

Error Deploying Rails on Dokku - on Digital Ocean

I'm trying to run dokku on DigitalOcean with a sample rails app, but when I deploy, I get this error:

      Puma starting in single mode...
       * Version 3.12.1 (ruby 2.6.3-p62), codename: Llamas in Pajamas
       * Min threads: 5, max threads: 5
       * Environment: production
       * Listening on tcp://0.0.0.0:5000
       bundler: failed to load command: rackup (/app/vendor/bundle/ruby/2.6.0/bin/rackup)
       Errno::ENOENT: No such file or directory @ rb_sysopen - tmp/pids/server.pid
         /app/vendor/bundle/ruby/2.6.0/gems/puma-3.12.1/lib/puma/launcher.rb:133:in `initialize'
         /app/vendor/bundle/ruby/2.6.0/gems/puma-3.12.1/lib/puma/launcher.rb:133:in `open'
         /app/vendor/bundle/ruby/2.6.0/gems/puma-3.12.1/lib/puma/launcher.rb:133:in `write_pid'
         /app/vendor/bundle/ruby/2.6.0/gems/puma-3.12.1/lib/puma/launcher.rb:106:in `write_state'
         /app/vendor/bundle/ruby/2.6.0/gems/puma-3.12.1/lib/puma/single.rb:103:in `run'
         /app/vendor/bundle/ruby/2.6.0/gems/puma-3.12.1/lib/puma/launcher.rb:186:in `run'
         /app/vendor/bundle/ruby/2.6.0/gems/puma-3.12.1/lib/rack/handler/puma.rb:73:in `run'
         /app/vendor/bundle/ruby/2.6.0/gems/rack-2.0.7/lib/rack/server.rb:297:in `start'
         /app/vendor/bundle/ruby/2.6.0/gems/rack-2.0.7/lib/rack/server.rb:148:in `start'
         /app/vendor/bundle/ruby/2.6.0/gems/rack-2.0.7/bin/rackup:4:in `<top (required)>'
         /app/vendor/bundle/ruby/2.6.0/bin/rackup:23:in `load'
         /app/vendor/bundle/ruby/2.6.0/bin/rackup:23:in `<top (required)>'

I've looked through other support sites for a similar error - but it looks like the web app container starts then immediately stops.

I can see my database container running, and I see a container with dokkku/myapp:latest - and it's never up for more than a few seconds.

Anyone have an idea why?

Upvotes: 7

Views: 1052

Answers (3)

Caleb
Caleb

Reputation: 3802

Rails 6 added a line to config/puma.rb that specifies the location of the pidfile (line 20 by default, at the time of my writing this), with the default value as follows:

pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }

I ran into the same problem you mentioned, and addressed it by changing that line to

pidfile ENV.fetch("PIDFILE") { "server.pid" }

Removing the tmp dir from both .gitignore and .dockerignore (in my case, since my app is Dockerized) also worked, but having tmp dirs in git and on my production containers smelled funny, so I opted for the aforementioned approach.

Either way, I'm glad you got it working! ... hope this helps

PS - you may want to consider selecting one of these answers as correct (even if it's an answer you provided) Happy coding!

Upvotes: 6

Daniel D
Daniel D

Reputation: 3677

Not sure why this is an issue - but my .gitignore file (a default, I think) kept the /tmp folder, but ignored contents, so there wasn't a /tmp/pids in the repo, and there probably wasn't on the web container.

I forced the /tmp/pids folder into the repo... and now it works!

Upvotes: 0

UsAndRufus
UsAndRufus

Reputation: 407

tmp/pids/server.pid is the file Rails uses to check if it is already running, and to check what process ID it is running with.

IIRC with Dokku, there is a user called dokku that all Dokku processes run under - make sure that user (or whichever user Dokku/the Rails app is running under), has read/write permission on that directory.

Alternatively, you may be able to just call touch tmp/pids/server.pid to create the file so that Rails can use it.

Upvotes: 0

Related Questions