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

Ansible has difficulty restarting Supervisor

· 52CE 我爱测

I'm trying to restart Supervisor through my Ansible Playbook but I seem to be stumbling into an issue with the supervisor module for Ansible. In my Supervisor config I have defined a program: [program:process] process_name=%(prog…

问题原文

原帖链接 · Luke · CC BY-SA 3.0

I'm trying to restart Supervisor through my Ansible Playbook but I seem to be stumbling into an issue with the supervisor module for Ansible.

In my Supervisor config I have defined a program:

[program:process]
process_name=%(program_name)s_%(process_num)02d
command=/home/box1/workers/bin/process
numprocs=64
directory=/home/box1/workers/bin
autostart=true
autorestart=true
startretries=5
stderr_logfile=/tmp/%(program_name)s-err.log
stdout_logfile=/tmp/%(program_name)s-out.log
user=root

And this works fine. However, when I try to restart Supervisor through Ansible I get the following error:

failed: [box1] => {"failed": true}
msg: program:process: ERROR (no such process)
program:process: ERROR (no such process)

My Ansible task configuration looks like this:

- name: Restart Supervisor
  sudo: yes
  supervisorctl: name=program:process state=restarted config=/etc/supervisor/supervisord.conf

For the name parameter I have tried program:process, program, program: and process but none seem to work. I'm currently on Ansible 1.5.4.

社区高分解答

原帖链接 · 300D7309EF17 · CC BY-SA 3.0

The supervisorctl Ansible module does not support the reload command (see here), which is needed for supervisor to pick up new configuration entries.

You can do it yourself like this:

- command: supervisorctl reread
  sudo: yes
- supervisorctl: name=program:process state=restarted config=/etc/supervisor/supervisord.conf
  sudo: yes

The documentation on reload/reread/update/restart seems to be missing, and this blog post is out of date; you can experiment to make sure reload does what you expect.

Finally, don't put your program definitions in supervisord.conf. Instead, put them as individual files in /etc/supervisor/conf.d/*.conf. That makes installation and maintenance much easier.

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

资料来源与适用范围

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

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

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