Permalink
Browse files

[COOK-794] nolog and default_logger options for runit_service definit…

…ion.
  • Loading branch information...
1 parent 0685710 commit 6400cb5c3ab29de150b3fd7dbe32f9c646e92743 @clkao clkao committed Sep 16, 2012
Showing with 37 additions and 12 deletions.
  1. +37 −12 definitions/runit_service.rb
@@ -17,7 +17,7 @@
# 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"
params[:directory] ||= node[:runit][:sv_dir]
@@ -40,18 +40,43 @@
action :create
end
- directory "#{sv_dir_name}/log" do
- owner params[:owner]
- group params[:group]
- mode 0755
- action :create
- end
+ unless params[:nolog]
+ directory "#{sv_dir_name}/log" do
+ owner params[:owner]
+ group params[:group]
+ mode 0755
+ action :create
+ end
- directory "#{sv_dir_name}/log/main" do
- owner params[:owner]
- group params[:group]
- mode 0755
- action :create
+ directory "#{sv_dir_name}/log/main" do
+ owner params[:owner]
+ group params[:group]
+ mode 0755
+ 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
template "#{sv_dir_name}/run" do

0 comments on commit 6400cb5

Please sign in to comment.