【发布时间】: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
我的理解是,日志的重启在服务的第一次设置时超时。
-
如何在机器第一次部署时只运行
:enable操作,而在所有其他部署时运行:usr2操作? - 我应该以不同的方式设置服务吗?
这是我的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
【问题讨论】: