0
votes

I'm using AWS OpsWorks (Chef 12.18.31, on ubuntu 14.04) and one of my chef recipes configures a runit_service with logs.

To set the service I need to use the action :enable but on every deploy of my code I need to use the action :usr2, so the action line is:

action [:enable, :usr2]

This causes a weird issue on the provisioning of a new machine, in which I get the following error:

================================================================================
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

The way I understand it, is that the restart of the logs gets timed out on the first setup of the service.

  1. How can I run only the :enable action on the first time the machine gets a deploy, but run the :usr2 action on all other deploys ?
  2. Should I set the service in a different way ?

This is my runit_service section:

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
1

1 Answers

0
votes

In normal Chef what you would want is :enable in the resource and :usr2 sent as a notification from the git resource or whatever is doing the actual deployment. This is a place where OpsWorks' event based nature deviates somewhat from normal Chef though but it's probably good enough.