-
Notifications
You must be signed in to change notification settings - Fork 197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[COOK-2353] split out config from enable action #20
Conversation
ensure templates are changed when service is running
@@ -250,6 +270,7 @@ def run_script | |||
@run_script.source("sv-#{new_resource.run_template_name}-run.erb") | |||
@run_script.cookbook(template_cookbook) | |||
@run_script.mode(00755) | |||
@run_script.notifies(:restart, "service[#{new_resource.service_name}]") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't seem to be working for me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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|
r.updated_by_last_action?
end
restart_service if scripts_updated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, untested code and all that :-). So really:
restart_service if run-script.updated_by_last_action?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about this:
restart_service if new_resource.restart_on_update and run_script.updated_by_last_action?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes and yes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 - 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. |
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/hash/has/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
[COOK-2353] split out config from enable action
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. :)