服务器重启后Puma无法启动

问题描述 投票:3回答:2

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

我应该做 - >帽制作美洲狮:每次都开始

我尝试过这个: /etc/init.d/myscript

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

puma_start.是

#!/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放在它的工作,所有的okey。

我想我没有正确的宝石美洲狮的道路

服务器重启后如何进行puma autostart 谢谢

ruby-on-rails linux capistrano puma start-stop-daemon
2个回答
1
投票

从Ubuntu 16.04开始,建议使用systemctl。在我使用暴发之前。我为自己创造了这个指令。也许对某人有用。

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

0
投票

我找到了这个http://codepany.com/blog/rails-5-puma-capistrano-nginx-jungle-upstart/

这对我有帮助 - >

cd ~
$ wget https://raw.githubusercontent.com/puma/puma/master/tools/jungle/upstart/puma-manager.conf
$ wget https://raw.githubusercontent.com/puma/puma/master/tools/jungle/upstart/puma.conf

打开下载的puma.conf文件,并为setuid和setguid设置系统的用户帐户。 (在我们的例子中,我们使用root帐户,但建议使用权限较低的帐户):

vim puma.conf

setuid root
setgid root

将下载的upstart文件移动到/ etc / init并创建另一个puma.conf

$ sudo cp puma.conf puma-manager.conf /etc/init
$ sudo touch /etc/puma.conf

打开/etc/puma.conf并添加app的路径:

/root/name_of_your_app/current

打开/etc/init/puma.conf,找到类似的东西

exec bundle exec puma -C /root/project/shared/puma.rb

并将路径替换为puma.rb文件

谢谢

© www.soinside.com 2019 - 2024. All rights reserved.