..$ rails s
=> Booting WEBrick
=> Rails 4.0.4 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=>
For added information, under the context of running the application in docker.
In docker-compose.yml file, under the application container itself, you can use one of the following:
command: ["rm /your-app-path/tmp/pids/server.pid && bundle exec bin/rails s -p 3000 -b '0.0.0.0'"]
or
command: ["rm /your-app-path/tmp/pids/server.pid; foreman start"]
Note the use of either ;
or &&
, that &&
will send an exit signal if rm
fails to find the file, forcing your container to prematurely stop. Using ;
will continue to execute.
Why is this caused in the first place? The rationale is that if the server (puma/thin/whatever) does not cleanly exit, it will leave a pid in the host machine causing an exit error.
For portability rather than manually deleting the file on the host system, it's better to check if the file exists within scripted or compose file itself.