5

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?

Daniel D
  • 3,477
  • 4
  • 32
  • 40

3 Answers3

5

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!

Caleb
  • 3,426
  • 2
  • 22
  • 27
  • 1
    FYI - I'm not saying you should check in the *contents* - just to have the structure there. Now is even that going too far? - I can see both sides to that issue - it makes sense for PIDS to be in a tmp folder. I would probably say Rails shouldn't be dictating a structure of a folder that is excluded from repos. – Daniel D Oct 04 '19 at 15:09
0

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.

UsAndRufus
  • 158
  • 3
  • 12
  • 1
    I set this up as a one click setup on Digital Ocean - and didn't give the 'dokku' user any special privileges - should that user be running as an admin? -- and thanks, I never thought this could be a permission issue. – Daniel D Sep 03 '19 at 12:40
0

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!

Daniel D
  • 3,477
  • 4
  • 32
  • 40
  • Glad you got it working buddy! You probably don't want to be comitting the `/tmp` folder into the repo though - by definition it's files that aren't consistent. The `pids` file will be different locally and on the server, and different every time you run the application. You may encounter issues when deploying the app if you do it like this. – UsAndRufus Sep 09 '19 at 10:31
  • 1
    FYI - not adding the tmp folder to a repo, just an empty folder for /tmp/pids and not checking in any contents. – Daniel D Oct 04 '19 at 15:05