【问题标题】:AWS OpsWorks Error: Supervisor service cannot be restarted because it does not existAWS OpsWorks 错误:无法重新启动主管服务,因为它不存在
【发布时间】:2014-02-26 17:25:23
【问题描述】:

我的 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 提供。

起初我尝试在运行实例中执行第一个配方。执行成功,supervisor运行顺利。

第二个秘诀基本上是更新主管运行的代码。所以我需要重新启动主管。但是每次执行服务时都会出现此错误。

================================================================================
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 不起作用。

【问题讨论】:

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


    【解决方案1】:

    我遇到了同样的错误,但这是由于主管说明书中的错误造成的。 https://github.com/poise/supervisor/issues/43

    我恢复到 Supervisor 食谱 0.4.2,它又可以正常工作了。

    【讨论】:

      【解决方案2】:

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

      include_recipe 'myserver::supervisor'
      

      【讨论】:

      • 你的意思是include_recipe 'supervisor'?还是我应该把它放在食谱myserver::supervisor
      • 我更新了代码。我是厨师(和 opsworks)的新手,请耐心等待。
      • 你开通服务了吗?
      • 我真的不知道那是什么意思,但是当我第一次执行supervisormyserver::supervisor 时,supervisord 服务出现了,并且程序mylistener 也在运行。所以我认为是的,它已启用。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-01
      • 1970-01-01
      • 2016-05-22
      • 2016-10-10
      • 1970-01-01
      • 2020-09-05
      相关资源
      最近更新 更多