Skip to content

Commit

Permalink
Add run_restart parameter to runit_service
Browse files Browse the repository at this point in the history
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
jtimberman committed May 4, 2010
1 parent bbb5aad commit 7c03340
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions runit/definitions/runit_service.rb
Expand Up @@ -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]

Expand Down Expand Up @@ -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
Expand All @@ -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

Expand Down

0 comments on commit 7c03340

Please sign in to comment.