How to get systemd to restart Rails App with Puma

后端 未结 2 1755
闹比i
闹比i 2021-02-08 00:20

I\'ve been struggling with this a week now and really can\'t seem to find an answer. I\'ve deployed my Rails App with Capistrano. I use Puma as a server.

When I deploy,

相关标签:
2条回答
  • 2021-02-08 00:43

    Have you looked into Foreman ? Foreman makes it easy to start and stop your application if it has multiple processes. Incidentally it also provides an export function that can generate some systemd or upstart scripts for you to (re)start and stop your application.

    As you are already using capistrano you can use capistrano-foreman to integrate all this nicely with capistrano.

    I hope you find some use in these resources

    0 讨论(0)
  • 2021-02-08 00:58

    At the end the problem was twofold: 1) rvm wasn't installed properly for all users, which meant the deployer user didn't have ruby/bundle/etc available and secondarily the script was also wrong. For reference below is the revised script that worked for me:

    [Unit]
    Description=Puma HTTP Server
    After=network.target
    
    [Service]
    Type=simple
    
    User=deployer
    
    WorkingDirectory=/var/www/apps/MRCbe/current
    
    ExecStart=/bin/bash -lc 'bundle exec puma -C /var/www/apps/MRCbe/shared/puma.rb'
    
    Restart=always
    
    [Install]
    WantedBy=multi-user.target
    
    0 讨论(0)
提交回复
热议问题