A server is already running. Check …/tmp/pids/server.pid. Exiting - rails

前端 未结 19 1445
礼貌的吻别
礼貌的吻别 2021-01-29 20:35
..$ 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
=>         


        
相关标签:
19条回答
  • 2021-01-29 21:06

    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.

    0 讨论(0)
提交回复
热议问题