AWS OpsWorks错误:无法重新启动Supervisor服务,因为它不存在

时间:2014-02-03 09:34:31

标签: amazon-web-services chef supervisord aws-opsworks

我的AWS OpsWorks自定义食谱中有两个食谱

第一个是myserver/recipes/supervisor.rb

 #myserver::supervisor

 supervisor_service "mylistener" do
      command "/usr/bin/php /var/www/listener.php"
      autostart true
      autorestart true
      numprocs 1
      process_name "%(program_name)s-%(process_num)s"
 end

,第二个是myserver/recipes/update_code.rb

 #myserver::update_code
 include_recipe "myserver::supervisor"
 execute "update_code" do
     command %Q {
         /usr/local/bin/downloadfile.sh
         /usr/local/bin/changelink.sh
     }
     notifies :restart, "supervisor_service[mylistener]"
 end

supervisor_servicehere提供。

首先,我尝试在运行实例中执行第一个配方。执行成功,主管运行顺利。

第二个方法基本上是更新主管运行的代码。所以我需要重新启动主管。但是每次我执行服务时都会遇到这个错误。

================================================================================
Error executing action `restart` on resource 'supervisor_service[mylistener]'
================================================================================


RuntimeError
------------
Supervisor service mylistener cannot be restarted because it does not exist


Resource Declaration:
---------------------
# In /opt/aws/opsworks/releases/20140116091718_218/site-cookbooks/myserver/recipes/supervisor.rb

9: supervisor_service "mylistener" do
10:     command "/usr/bin/php /var/www/listener.php"
11:     autostart true
12:     autorestart true
13:     numprocs 1
14:     process_name "%(program_name)s-%(process_num)s"
15: end

我做错了什么?

更新

我将include_recipe 'supervisor'放入文件myserver/recipes/supervisor.rb

#myserver::supervisor
include_recipe 'supervisor'

supervisor_service "mylistener" do
    command "/usr/bin/php /var/www/listener.php"
    autostart true
    autorestart true
    numprocs 1
    process_name "%(program_name)s-%(process_num)s"
end

但是当我在AWS OpsWorks中执行myserver::update_code时,它仍然会在下面返回错误,但是会有一个新的Compiled Resource部分。

================================================================================
Error executing action `restart` on resource 'supervisor_service[mylistener]'
================================================================================


RuntimeError
------------
Supervisor service mylistener cannot be restarted because it does not exist


Resource Declaration:
---------------------
# In /opt/aws/opsworks/releases/20140116091718_218/site-cookbooks/myrecipe/recipes/supervisor.rb

11: supervisor_service "mylistener" do
12:     command "/usr/bin/php /var/www/listener.php"
13:     autostart true
14:     autorestart true
15:     numprocs 1
16:     process_name "%(program_name)s-%(process_num)s"
17: end

Compiled Resource:
------------------
# Declared in /opt/aws/opsworks/releases/20140116091718_218/site-cookbooks/myserver/recipes/supervisor.rb:11:in `from_file'

supervisor_service("mylistener") do
priority 999
numprocs_start 0
autorestart true
retries 0
updated true
stderr_capture_maxbytes "0"
exitcodes [0, 2]
stderr_logfile "/var/log/mylistener.err.log"
cookbook_name :myserver
stdout_capture_maxbytes "0"
autostart true
recipe_name "supervisor"
serverurl "AUTO"
action :enable
stderr_logfile_backups 10
startretries 3
process_name "%(program_name)s-%(process_num)s"
stdout_logfile_backups 10
stopwaitsecs 10
stderr_logfile_maxbytes "50MB"
startsecs 1
numprocs 1
retry_delay 2
stdout_logfile_maxbytes "50MB"
command "/usr/bin/php /var/www/listener.php"
stopsignal :TERM
service_name "mylistener"
stdout_logfile "/var/log/mylistener.out.log"
end

更新

我终于使用了这个手动执行

execute "supervisor-restart-mylistener" do
    command "supervisorctl restart mylistener:*"
end

但仍在试图找出notifies无效的原因。

2 个答案:

答案 0 :(得分:1)

我得到了同样的错误,但这是由于主管食谱中的一个错误。 https://github.com/poise/supervisor/issues/43

我又回到了主管食谱0.4.2,它再次正常工作。

答案 1 :(得分:0)

除非您在run_list中包含这两个配方或使用include_recipe,否则此错误是正确的。如果update_code.rb通知supervisor_service,那么supervisor.rb食谱就是该食谱的“依赖关系”。您应该将以下内容添加到update_code.rb的顶部:

include_recipe 'myserver::supervisor'