Permalink
Browse files

Add run_restart parameter to runit_service

This parameter allows users of the runit_service definition to control
whether the service resource created by the definition will be restarted
when the 'run' script is changed.
  • Loading branch information...
1 parent 8aec731 commit 389a96323d0e429534b3bc32830931a1a2173865 @jtimberman jtimberman committed May 4, 2010
Showing with 5 additions and 5 deletions.
  1. +5 −5 definitions/runit_service.rb
@@ -17,7 +17,7 @@
# limitations under the License.
#
-define :runit_service, :directory => nil, :only_if => false, :finish_script => false, :control => [], :options => Hash.new do
+define :runit_service, :directory => nil, :only_if => false, :finish_script => false, :control => [], :run_restart => true, :options => Hash.new do
params[:directory] ||= node[:runit][:sv_dir]
@@ -97,8 +97,7 @@
ruby_block "supervise_#{params[:name]}_sleep" do
block do
Chef::Log.debug("Waiting until named pipe #{sv_dir_name}/supervise/ok exists.")
- (1..8).each {|i| sleep 1 unless ::FileTest.pipe?("#{sv_dir_name}/supervise/ok") }
- Chef::Log.debug("Named pipe #{sv_dir_name}/supervise/ok exists, continuing.")
+ (1..10).each {|i| sleep 1 unless ::FileTest.pipe?("#{sv_dir_name}/supervise/ok") }
end
not_if { FileTest.pipe?("#{sv_dir_name}/supervise/ok") }
end
@@ -110,8 +109,9 @@
stop_command "#{node[:runit][:sv_bin]} stop #{params[:name]}"
restart_command "#{node[:runit][:sv_bin]} restart #{params[:name]}"
status_command "#{node[:runit][:sv_bin]} status #{params[:name]}"
- subscribes :restart, resources(:template => "#{sv_dir_name}/run"), :delayed
- subscribes :restart, resources(:template => "#{sv_dir_name}/log/run"), :delayed
+ if params[:run_restart]
+ subscribes :restart, resources(:template => "#{sv_dir_name}/run"), :delayed
+ end
action :nothing
end

0 comments on commit 389a963

Please sign in to comment.