简体   繁体   English

puma systemd 脚本不启动 puma

[英]puma systemd script doesn't start puma

I've been copy and pasting snippets of the following puma systems start script from multiple sources but it doesn't work.我一直在从多个来源复制和粘贴以下 puma 系统启动脚本的片段,但它不起作用。 The system is a Debian 9.6 and the user rails has ruby installed via rvm .该系统是 Debian 9.6,用户rails已通过rvm安装了rvm The user rails can start the command RAILS_ENV=production bundle exec puma -C /var/www/test-optimum/current/config/puma.rb --daemon用户rails可以启动命令RAILS_ENV=production bundle exec puma -C /var/www/test-optimum/current/config/puma.rb --daemon

What is wrong with this script?这个脚本有什么问题?

[Unit]
Description=Test Puma HTTP Server
After=network.target

[Service]
Type=simple
User=rails
WorkingDirectory=/var/www/test-optimum/current
ExecStart=/bin/bash -lc 'RAILS_ENV=production bundle exec puma -C /var/www/test-optimum/current/config/puma.rb --daemon'
ExecStop=/home/rails/.rvm/bin/rvm default do bundle exec pumactl -S /var/www/test-optimum/shared/tmp/pids/puma.pid stop

PIDFile=/var/www/test-optimum/shared/tmp/pids/puma.pid
Restart=always

[Install]
WantedBy=multi-user.target

When trying to start it with systemctl start puma I get this errors:尝试使用systemctl start puma启动它时,出现以下错误:

● test-puma.service - test Puma HTTP Server
  Loaded: loaded (/etc/systemd/system/test-puma.service; disabled; vendor preset: enabled)
  Active: failed (Result: exit-code) since Fri 2019-01-04 17:10:43 CET; 6min ago
  Process: 3351 ExecStop=/home/rails/.rvm/bin/rvm default do bundle exec pumactl -S /var/www/test-optimum/shared/tmp/pids/puma.pid stop (code=exited, status=1/FAILURE)
  Process: 3239 ExecStart=/bin/bash -lc RAILS_ENV=production bundle exec puma -C /var/www/test-optimum/current/config/puma.rb --daemon (code=exited, status=0/SUCCESS)
Main PID: 3239 (code=exited, status=0/SUCCESS)
      CPU: 1.179s

Jan 04 17:10:42 test.example.com systemd[1]: test-puma.service: Unit entered failed state.
Jan 04 17:10:42 test.example.com systemd[1]: test-puma.service: Failed with result 'exit-code'.
Jan 04 17:10:43 test.example.com systemd[1]: test-puma.service: Service hold-off time over, scheduling restart.
Jan 04 17:10:43 test.example.com systemd[1]: Stopped test Puma HTTP Server.
Jan 04 17:10:43 test.example.com systemd[1]: test-puma.service: Start request repeated too quickly.
Jan 04 17:10:43 test.example.com systemd[1]: Failed to start test Puma HTTP Server.
Jan 04 17:10:43 test.example.com systemd[1]: test-puma.service: Unit entered failed state.
Jan 04 17:10:43 test.example.com systemd[1]: test-puma.service: Failed with result 'exit-code'.

Here's the solution:这是解决方案:

[Unit]
Description=Test Puma HTTP Server
After=network.target

[Service]
Type=simple
User=rails
WorkingDirectory=/var/www/test-optimum/current
ExecStart=/bin/bash -lc 'RAILS_ENV=production bundle exec puma -C /var/www/test-optimum/current/config/puma.rb'
ExecStop=/home/rails/.rvm/bin/rvm default do bundle exec pumactl -S /var/www/test-optimum/shared/tmp/pids/puma.pid stop

PIDFile=/var/www/test-optimum/shared/tmp/pids/puma.pid
Restart=always

[Install]
WantedBy=multi-user.target

What is wrong with this script?这个脚本有什么问题?

Probably just the type of the service:可能只是服务的类型:

Main PID: 3239 (code=exited, status= 0 /SUCCESS)主PID:3239(代码=退出,状态= 0 /成功)

Seems the main process is forking.似乎主要过程是分叉。 Try forking instead of simple : https://www.freedesktop.org/software/systemd/man/systemd.service.html#Options尝试forking而不是simplehttps : //www.freedesktop.org/software/systemd/man/systemd.service.html#Options

在我的情况下,我在ExecStart更新到这样的东西时有错误的命令ExecStart=/bin/bash -lc 'RAILS_ENV=production bundle exec puma -C /home/ubuntu/rails_current_server/config/puma.rb'

An improved solution could be:改进的解决方案可能是:

[Unit]
Description=Test Puma HTTP Server
After=network.target

[Service]
Type=simple
User=rails
WorkingDirectory=/var/www/test-optimum/current
ExecStart=/home/rails/.rvm/bin/rvm default do bundle exec puma -C /var/www/test-optimum/current/config/puma.rb --daemon
ExecStop=/home/rails/.rvm/bin/rvm default do bundle exec pumactl -S /var/www/test-optimum/shared/tmp/pids/puma.pid stop

PIDFile=/var/www/test-optimum/shared/tmp/pids/puma.pid
Restart=always

[Install]
WantedBy=multi-user.target

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM