Skip to content

Commit

Permalink
Merge pull request #6 from clkao-cookbooks/COOK-794
Browse files Browse the repository at this point in the history
[COOK-794] nolog and default_logger options for runit_service definition...
  • Loading branch information
Joshua Timberman committed Nov 3, 2012
2 parents 0685710 + 6400cb5 commit b2d8bab
Showing 1 changed file with 37 additions and 12 deletions.
49 changes: 37 additions & 12 deletions definitions/runit_service.rb
Expand Up @@ -17,7 +17,7 @@
# limitations under the License. # limitations under the License.
# #


define :runit_service, :directory => nil, :only_if => false, :finish_script => false, :control => [], :run_restart => true, :active_directory => nil, :owner => "root", :group => "root", :template_name => nil, :log_template_name => nil, :control_template_names => {}, :finish_script_template_name => nil, :start_command => "start", :stop_command => "stop", :restart_command => "restart", :status_command => "status", :options => Hash.new, :env => Hash.new do define :runit_service, :directory => nil, :only_if => false, :finish_script => false, :control => [], :run_restart => true, :active_directory => nil, :owner => "root", :group => "root", :template_name => nil, :log_template_name => nil, :control_template_names => {}, :finish_script_template_name => nil, :start_command => "start", :stop_command => "stop", :restart_command => "restart", :status_command => "status", :options => Hash.new, :env => Hash.new, :default_logger => false, :nolog => false do
include_recipe "runit" include_recipe "runit"


params[:directory] ||= node[:runit][:sv_dir] params[:directory] ||= node[:runit][:sv_dir]
Expand All @@ -40,18 +40,43 @@
action :create action :create
end end


directory "#{sv_dir_name}/log" do unless params[:nolog]
owner params[:owner] directory "#{sv_dir_name}/log" do
group params[:group] owner params[:owner]
mode 0755 group params[:group]
action :create mode 0755
end action :create
end


directory "#{sv_dir_name}/log/main" do directory "#{sv_dir_name}/log/main" do
owner params[:owner] owner params[:owner]
group params[:group] group params[:group]
mode 0755 mode 0755
action :create action :create
end

if params[:default_logger]
file "#{sv_dir_name}/log/run" do
owner params[:owner]
group params[:group]
mode 0755
content <<-EOF
#!/bin/sh
exec svlogd -tt ./main
EOF
end
else
template "#{sv_dir_name}/log/run" do
owner params[:owner]
group params[:group]
mode 0755
source "sv-#{params[:log_template_name]}-log-run.erb"
cookbook params[:cookbook] if params[:cookbook]
if params[:options].respond_to?(:has_key?)
variables :options => params[:options]
end
end
end
end end


template "#{sv_dir_name}/run" do template "#{sv_dir_name}/run" do
Expand Down

0 comments on commit b2d8bab

Please sign in to comment.