10

I have an application that I successfully uploaded to Heroku and everything worked fine. After updating with the rails app:update command from version 6.0.0rc1 to 6.0.0, I deployed the application to heroku and after that the Heroku is crashed when the server launch.

2019-08-20T12:45:56.047319+00:00 heroku[web.1]: State changed from crashed to starting
2019-08-20T12:46:01.995009+00:00 heroku[web.1]: Starting process with command `bundle exec puma -t 5:5 -p ${PORT:-3000} -e ${RACK_ENV:-development}`
2019-08-20T12:46:04.051365+00:00 app[web.1]: Puma starting in single mode...
2019-08-20T12:46:04.051387+00:00 app[web.1]: * Version 3.12.1 (ruby 2.6.1-p33), codename: Llamas in Pajamas
2019-08-20T12:46:04.051389+00:00 app[web.1]: * Min threads: 5, max threads: 5
2019-08-20T12:46:04.051390+00:00 app[web.1]: * Environment: production
2019-08-20T12:46:08.886669+00:00 heroku[web.1]: State changed from starting to crashed
2019-08-20T12:46:08.769945+00:00 app[web.1]: * Listening on tcp://0.0.0.0:32178
2019-08-20T12:46:08.770225+00:00 app[web.1]: bundler: failed to load command: puma (/app/vendor/bundle/ruby/2.6.0/bin/puma)
2019-08-20T12:46:08.770272+00:00 app[web.1]: Errno::ENOENT: No such file or directory @ rb_sysopen - tmp/pids/server.pid
2019-08-20T12:46:08.770276+00:00 app[web.1]: /app/vendor/bundle/ruby/2.6.0/gems/puma-3.12.1/lib/puma/launcher.rb:133:in `initialize'
2019-08-20T12:46:08.770277+00:00 app[web.1]: /app/vendor/bundle/ruby/2.6.0/gems/puma-3.12.1/lib/puma/launcher.rb:133:in `open'
2019-08-20T12:46:08.770278+00:00 app[web.1]: /app/vendor/bundle/ruby/2.6.0/gems/puma-3.12.1/lib/puma/launcher.rb:133:in `write_pid'
2019-08-20T12:46:08.770280+00:00 app[web.1]: /app/vendor/bundle/ruby/2.6.0/gems/puma-3.12.1/lib/puma/launcher.rb:106:in `write_state'
2019-08-20T12:46:08.770281+00:00 app[web.1]: /app/vendor/bundle/ruby/2.6.0/gems/puma-3.12.1/lib/puma/single.rb:103:in `run'
2019-08-20T12:46:08.770282+00:00 app[web.1]: /app/vendor/bundle/ruby/2.6.0/gems/puma-3.12.1/lib/puma/launcher.rb:186:in `run'
2019-08-20T12:46:08.770284+00:00 app[web.1]: /app/vendor/bundle/ruby/2.6.0/gems/puma-3.12.1/lib/puma/cli.rb:80:in `run'
2019-08-20T12:46:08.770285+00:00 app[web.1]: /app/vendor/bundle/ruby/2.6.0/gems/puma-3.12.1/bin/puma:10:in `<top (required)>'
2019-08-20T12:46:08.770287+00:00 app[web.1]: /app/vendor/bundle/ruby/2.6.0/bin/puma:23:in `load'
2019-08-20T12:46:08.770289+00:00 app[web.1]: /app/vendor/bundle/ruby/2.6.0/bin/puma:23:in `<top (required)>'
2019-08-20T12:46:08.867275+00:00 heroku[web.1]: Process exited with status 1

For some reason, the tmp/pids/server.pid is not created when the server starts.

Can you please help me with a solution to this problem? I did not find a solution in google

Holger Just
  • 52,918
  • 14
  • 115
  • 123
Daniel Pogosyan
  • 431
  • 5
  • 11

3 Answers3

16

You'll need to modify your .gitignore file to explicitly let through the tmp/pids directory with a .keep file. Ensure your .gitignore looks like this:

/tmp/*
/tmp/pids/*
!/tmp/.keep
!/tmp/pids
!/tmp/pids/.keep

And then touch tmp/pids/.keep.

bswinnerton
  • 4,533
  • 8
  • 41
  • 56
  • didn't work... pids folder is not pushed to heroku got error-> launcher.rb:244:in `write': No such file or directory @ rb_sysopen - tmp/pids/server.pid (Errno::ENOENT) – Rahul Dec 17 '20 at 10:13
  • This happened to me when I upgrade to 5.2.6 however there was `Ignore pidfiles, but keep the directory.` part in `.gitignore` file when `rails new`. – kangkyu Sep 02 '21 at 19:46
  • This worked for me on Heroku. – B-Rad Jan 20 '22 at 20:14
14

Ok, I solved the problem by removing the line pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" } from the config/puma.rb that was added during the rails upgrade :)

Daniel Pogosyan
  • 431
  • 5
  • 11
2

You can add the tmp/pids folder to version control using a .keep file. This puts the folder in version control, so when it gets cloned to Heroku, the folder is there.

You will also probably have to edit your .gitignore file so it doesn't ignore the tmp/pids directory.

PJ Davis
  • 822
  • 5
  • 6