[COOK-2353] split out config from enable action #20

merged 5 commits into from Feb 28, 2013


None yet

3 participants


This will ensure templates are changed when service is already running. Seems to be working for me but definitely needs to be looked over. There might be a better way to get this done. :)

@dwradcliffe dwradcliffe and 1 other commented on an outdated diff Feb 19, 2013
@@ -250,6 +270,7 @@ def run_script
+ @run_script.notifies(:restart, "service[#{new_resource.service_name}]")
dwradcliffe Feb 19, 2013 Contributor

This doesn't seem to be working for me.

jtimberman Feb 20, 2013 Member

From Seth, how about something like this at the end of the action_enable method?

scripts_updated = [ run_script, log_run_script, finish_script, control_signal_files ].flatten.any? do |r| 

restart_service if scripts_updated
dwradcliffe Feb 20, 2013 Contributor

The finish and control scripts shouldn't need a restart, since they are run from disk at the time they are called.
I'm still on the fence about the log script, and the more I think about it I'd really like to be able to NOT restart the service in either case.

Example: We use unicorn, and do zero-downtime deploys using USR2 to restart. I really want to control when a restart or a full restart happens, and it's almost never going to be at the time of a chef run.

jtimberman Feb 20, 2013 Member

yeah, untested code and all that :-). So really:

restart_service if run-script.updated_by_last_action?
dwradcliffe Feb 20, 2013 Contributor

How about this:

restart_service if new_resource.restart_on_update and run_script.updated_by_last_action?
jtimberman Feb 21, 2013 Member

Where is restart_on_update? Is that a new attribute you're proposing? Would it be true by default so existing recipes wouldn't need to be updated?

dwradcliffe Feb 21, 2013 Contributor

Yes and yes.

jtimberman Feb 22, 2013 Member

👍 - make sure we have test coverage. :)


Tests added for restart_on_update attribute. All tests passing. Might be good to add a test for the new restart action.

@stevendanna stevendanna and 1 other commented on an outdated diff Feb 25, 2013
@@ -164,6 +164,15 @@
resource.default_logger.should be_true
+ it 'has a restart_on_update parameter that is true by default' do
+ resource.restart_on_update.should be_true
+ end
+ it 'hash a restart_on_update parameter that controls whether a the service is restarted when the run script is updated' do
@jtimberman jtimberman merged commit cfa5cfc into chef-cookbooks:master Feb 28, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment