【问题标题】:Running one chef recipe action on first run, but another on every deploy在第一次运行时运行一个厨师食谱操作,但在每次部署时运行另一个
【发布时间】:2017-11-30 13:18:41
【问题描述】:

我正在使用 AWS OpsWorks(Chef 12.18.31,在 ubuntu 14.04 上)并且我的一个厨师食谱配置了带有日志的 runit_service

要设置服务,我需要使用操作:enable,但在每次部署我的代码时,我都需要使用操作:usr2,因此action 行是:

action [:enable, :usr2]

这会导致配置新机器时出现奇怪的问题,我收到以下错误:

================================================================================
Error executing action `run` on resource 'ruby_block[restart_log_service]'
================================================================================

Mixlib::ShellOut::ShellCommandFailed
------------------------------------
Expected process to exit with [0], but received '1'
---- Begin output of /usr/bin/sv -w '40' restart /etc/service/my_app/log ----
STDOUT: timeout: run: /etc/service/my_app/log: (pid 28431) 42s, got TERM
STDERR: 
---- End output of /usr/bin/sv -w '40' restart /etc/service/my_app/log ----
Ran /usr/bin/sv -w '40' restart /etc/service/my_app/log returned 1

我的理解是,日志的重启在服务的第一次设置时超时。

  1. 如何在机器第一次部署时只运行:enable 操作,而在所有其他部署时运行:usr2 操作?
  2. 我应该以不同的方式设置服务吗?

这是我的runit_service 部分:

runit_service app['shortname'] do
  run_template_name 'rails-application'
  env app['environment']
  default_logger true
  log_dir "/log/#{app['shortname']}"
  log_num 10
  log_min 3
  sv_timeout 40
  options(
    :application_name => app['shortname'],
    :path => app_deploy_path,
    :bundle_command => 'bundle',
    :rails_env => app['environment']['RAILS_ENV']
  )

  action [:enable, :usr2]
end

【问题讨论】:

    标签: chef-infra aws-opsworks


    【解决方案1】:

    在普通 Chef 中,您想要的是资源中的 :enable:usr2 作为来自 git 资源或执行实际部署的通知的通知。虽然这是 OpsWorks 基于事件的性质与普通 Chef 有所不同的地方,但它可能已经足够好了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-08-21
      • 1970-01-01
      相关资源
      最近更新 更多