Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 728
Daniel D Avatar asked Sep 03 '19 02:09

Daniel D


1 Answers

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!

like image 80
Caleb Avatar answered Oct 18 '22 06:10

Caleb