gpt4 book ai didi

ruby-on-rails - puma systemd 脚本不启动 puma

转载 作者:行者123 更新时间:2023-12-04 00:28:56 25 4
gpt4 key购买 nike

我一直在从多个来源复制和粘贴以下 puma 系统启动脚本的片段,但它不起作用。系统是Debian 9.6,用户rails通过 rvm 安装了 ruby .用户 rails可以启动命令RAILS_ENV=production bundle exec puma -C /var/www/test-optimum/current/config/puma.rb --daemon
这个脚本有什么问题?

[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

尝试使用 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'.

最佳答案

这是解决方案:

[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

关于ruby-on-rails - puma systemd 脚本不启动 puma,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54042621/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com