Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

[COOK-794] nolog and default_logger options for runit_service definition... #6

Merged
merged 1 commit into from

2 participants

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 37 additions and 12 deletions.
  1. +37 −12 definitions/runit_service.rb
View
49 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
Something went wrong with that request. Please try again.