使用 systemd 和 rvm 启动 puma
创建文件 /etc/systemd/system/puma-site-1.service
[Unit]
Description=Puma
After=network.target
[Service]
EnvironmentFile=/etc/sysconfig/ruby-2.3.0
ExecStart=/usr/local/rvm/gems/ruby-2.3.0/bin/bundle exec puma -C config/puma.rb
WorkingDirectory=/u/apps/[site-1]/current
[Install]
WantedBy=multi-user.target
其中 EnvironmentFile /etc/sysconfig/ruby-2.3.0 的内容:
这样生成:
env | grep '^PATH\|GEM_HOME\|GEM_PATH' > /etc/sysconfig/ruby-2.3.0
内容是这样
GEM_HOME=...
PATH=...
GEM_PATH...
启动:
systemctl start puma-site-1.service