大网数据广告活动
服务器运维问答

Ansible hangs on pumactl start

· 52CE 我爱测

I have a playbook to install puma on my ec2 instance and everything is fine except when I run bundle exec pumactl start at the the end it starts the server but the playbook hangs indefinitely. Here is the Ansible task - - shell: …

问题原文

原帖链接 · Ryan Grush · CC BY-SA 4.0

I have a playbook to install puma on my ec2 instance and everything is fine except when I run bundle exec pumactl start at the the end it starts the server but the playbook hangs indefinitely.

Here is the Ansible task -

 - shell: /home/ubuntu/.rbenv/shims/bundle exec pumactl start
   args: 
     chdir: /home/{{ user }}/{{ app_name }}
     warn: no

Is there a way to avoid this?

Update

I added this to my /etc/systemd/system/puma.service file and ran it with systemd as @Michael suggested -

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

[Service]
Type=simple
User=ubuntu
WorkingDirectory=/home/ubuntu/my_app
ExecStart=/bin/bash -lc '/home/ubuntu/.rbenv/shims/bundle exec puma -C /home/ubuntu/my_app/config/puma.rb'
ExecStop=/bin/bash -lc '/home/ubuntu/.rbenv/shims/bundle exec pumactl -S /home/ubuntu/my_app/shared/pids/puma.state stop'
TimeoutSec=15
Restart=always

[Install]
WantedBy=multi-user.target

已采纳解答

原帖链接 · Michael Hampton · CC BY-SA 4.0

You forgot to daemonize puma, so it's running in the foreground. Ansible has been waiting for it to exit. Add the -d option to the command.

Better yet, you should create a systemd unit to run puma as a service, and then start that service. Daemonizing is not required in that case, as systemd will handle everything.

BTW, it is best practice to use command instead of shell unless you actually need shell processing (which in this case you do not).

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2018-07-25)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。