ruby-on-rails - puma systemd 脚本不启动 puma
问题描述
我一直在从多个来源复制和粘贴以下 puma 系统启动脚本的片段,但它不起作用。系统是 Debian 9.6,用户rails
通过rvm
. 用户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
推荐阅读
- php - 如何 php lint 仅在 gitlab 中存在和修改文件?
- android - 在 WebView 中存储和使用 Cookie
- arangodb - ArangoDB - 创建 AQL 插入脚本
- python - Python3内存错误的根源是什么?以及如何解决?
- jenkins - 在现有 Jenkins 实例上初始安装后,Jenkins Blue Ocean 未加载
- java - 在这种情况下,Observable 会因为被垃圾收集而停止发射吗?
- excel - 如何计数直到某个值?
- sql - linq 内连接子查询和条件选择
- google-app-maker - 是否可以安全地强制用户只能通过关系访问数据?
- angular - Angular4:在 model.valueAccessor.writeValue( value ) 之后输入未正确更新