gpt4 book ai didi

ruby-on-rails - 服务器重启后 Puma 不启动

转载 作者:太空狗 更新时间:2023-10-29 11:17:31 25 4
gpt4 key购买 nike

我用 capistrano 部署了项目,但是服务器重启后 puma 没有启动..

我应该做 -> cap production puma:start every time

我试过了:

/etc/init.d/myscript

#!/bin/sh
/etc/init.d/puma_start.sh

puma_start.sh

#!/bin/bash 
puma -C /root/project/shared/puma.rb

但是,我有错误

/usr/local/rvm/rubies/ruby-2.3.3/lib/ruby/site_ruby/2.3.0/rubygems.rb:270:in `find_spec_for_exe': can't find gem puma (>= 0.a) (Gem::GemNotFoundException)
from /usr/local/rvm/rubies/ruby-2.3.3/lib/ruby/site_ruby/2.3.0/rubygems.rb:298:in `activate_bin_path'
from /usr/local/rvm/gems/ruby-2.3.3@project/bin/puma:22:in `<main>'
from /usr/local/rvm/gems/ruby-2.3.3@project/bin/ruby_executable_hooks:15:in `eval'
from /usr/local/rvm/gems/ruby-2.3.3@project/bin/ruby_executable_hooks:15:in `<main>'

如果我在控制台中输入 root@host:~# puma -C/root/project/shared/puma.rb 它可以工作,一切正常。

我想我没有正确的 gem puma 路径

服务器重启后如何让puma自动启动
谢谢你

最佳答案

从 Ubuntu 16.04 开始推荐使用 systemctl。在我使用 Upstart 之前。我为自己创建了这个指令。也许对某人有用。

https://gist.github.com/DSKonstantin/708f346f1cf62fb6d61bf6592e480781


说明:

Article: https://github.com/puma/puma/blob/master/docs/systemd.md
#1 nano /etc/systemd/system/puma.service
#2 paste from puma.service

Commands:
# After installing or making changes to puma.service
systemctl daemon-reload

# Enable so it starts on boot
systemctl enable puma.service

# Initial start up.
systemctl start puma.service

# Check status
systemctl status puma.service

# A normal restart. Warning: listeners sockets will be closed
# while a new puma process initializes.
systemctl restart puma.service

puma.service 文件

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

[Service]
Type=simple

User=root
Group=root

WorkingDirectory=<path_to_project>/current
Environment=SECRET_KEY_BASE='<SECRET KEY>'

ExecStart=/usr/local/rvm/bin/rvm <ruby_version>@<gemset_name> do bundle exec puma -C <path_to_project>/shared/puma.rb --daemon
ExecStop=/usr/local/rvm/bin/rvm <ruby_version>@<gemset_name> do bundle exec pumactl -S <path_to_project>/shared/tmp/pids/puma.state -F <path_to_project>/shared/puma.rb stop

#Restart=always
Restart=on-failure

[Install]
WantedBy=multi-user.target

关于ruby-on-rails - 服务器重启后 Puma 不启动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43300232/

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