diff --git a/Rakefile b/Rakefile index 926378c4fb9e2a4e4d134efef5f485591a28fd3e..76da9068edc38a2f053ed2adcb10d03024284d59 100644 --- a/Rakefile +++ b/Rakefile @@ -6,5 +6,5 @@ Knapsack.load_tasks require 'rubocop/rake_task' RuboCop::RakeTask.new(:rubocop) do |t| - t.options = ['-D', 'config', 'lib', 'spec', 'files/gitlab-ctl-commands', 'files/gitlab-cookbooks/gitlab-ee'] + t.options = ['-D', 'config', 'lib', 'spec', 'files/gitlab-ctl-commands', 'files/gitlab-cookbooks/gitlab-ee', 'files/gitlab-cookbooks/runit'] end diff --git a/files/gitlab-cookbooks/runit/attributes/default.rb b/files/gitlab-cookbooks/runit/attributes/default.rb index 776d7da6546e66970f3ffc7c795312ff28e1f575..ea4dc47db24cc99f72ebaa92e323f8e1dce15eec 100644 --- a/files/gitlab-cookbooks/runit/attributes/default.rb +++ b/files/gitlab-cookbooks/runit/attributes/default.rb @@ -22,4 +22,3 @@ default[:runit][:sv_bin] = "/opt/gitlab/embedded/bin/sv" default[:runit][:chpst_bin] = "/opt/gitlab/embedded/bin/chpst" default[:runit][:service_dir] = "/opt/gitlab/service" default[:runit][:sv_dir] = "/opt/gitlab/sv" - diff --git a/files/gitlab-cookbooks/runit/definitions/runit_service.rb b/files/gitlab-cookbooks/runit/definitions/runit_service.rb index 7a3c6f1a4534eb003ebd8374f0edc0e8ce2a2e99..38aec37293a09cf9f046169a6aa241e338ea5d42 100644 --- a/files/gitlab-cookbooks/runit/definitions/runit_service.rb +++ b/files/gitlab-cookbooks/runit/definitions/runit_service.rb @@ -18,8 +18,7 @@ # limitations under the License. # -define :runit_service, :directory => nil, :only_if => false, :finish_script => false, :control => [], :run_restart => true, :active_directory => nil, :init_script_template => nil, :owner => "root", :group => "root", :template_name => nil, :start_command => "start", :stop_command => "stop", :restart_command => "restart", :status_command => "status", :options => Hash.new, :log_options => Hash.new, :env => Hash.new, :action => :enable, :down => false do - +define :runit_service, directory: nil, only_if: false, finish_script: false, control: [], run_restart: true, active_directory: nil, init_script_template: nil, owner: "root", group: "root", template_name: nil, start_command: "start", stop_command: "stop", restart_command: "restart", status_command: "status", options: {}, log_options: {}, env: {}, action: :enable, down: false do include_recipe "runit" omnibus_helper = OmnibusHelper.new(node) @@ -30,12 +29,11 @@ define :runit_service, :directory => nil, :only_if => false, :finish_script => f sv_dir_name = "#{params[:directory]}/#{params[:name]}" service_dir_name = "#{params[:active_directory]}/#{params[:name]}" - params[:options].merge!(:env_dir => "#{sv_dir_name}/env") unless params[:env].empty? + params[:options][:env_dir] = "#{sv_dir_name}/env" unless params[:env].empty? case params[:action] when :enable - directory sv_dir_name do owner params[:owner] group params[:group] @@ -64,7 +62,7 @@ define :runit_service, :directory => nil, :only_if => false, :finish_script => f source "sv-#{params[:template_name]}-run.erb" cookbook params[:cookbook] if params[:cookbook] if params[:options].respond_to?(:has_key?) - variables :options => params[:options] + variables options: params[:options] end end @@ -75,7 +73,7 @@ define :runit_service, :directory => nil, :only_if => false, :finish_script => f source "sv-#{params[:template_name]}-log-run.erb" cookbook params[:cookbook] if params[:cookbook] if params[:options].respond_to?(:has_key?) - variables :options => params[:options] + variables options: params[:options] end end @@ -128,7 +126,7 @@ define :runit_service, :directory => nil, :only_if => false, :finish_script => f source "sv-#{params[:template_name]}-finish.erb" cookbook params[:cookbook] if params[:cookbook] if params[:options].respond_to?(:has_key?) - variables :options => params[:options] + variables options: params[:options] end end end @@ -149,7 +147,7 @@ define :runit_service, :directory => nil, :only_if => false, :finish_script => f source "sv-#{params[:template_name]}-control-#{signal}.erb" cookbook params[:cookbook] if params[:cookbook] if params[:options].respond_to?(:has_key?) - variables :options => params[:options] + variables options: params[:options] end end end @@ -162,14 +160,12 @@ define :runit_service, :directory => nil, :only_if => false, :finish_script => f mode 0755 source params[:init_script_template] if params[:options].respond_to?(:has_key?) - variables :options => params[:options] + variables options: params[:options] end end - else - if params[:active_directory] == node[:runit][:service_dir] - link "/opt/gitlab/init/#{params[:name]}" do - to node[:runit][:sv_bin] - end + elsif params[:active_directory] == node[:runit][:service_dir] + link "/opt/gitlab/init/#{params[:name]}" do + to node[:runit][:sv_bin] end end @@ -182,7 +178,7 @@ define :runit_service, :directory => nil, :only_if => false, :finish_script => f ruby_block "supervise_#{params[:name]}_sleep" do block do Chef::Log.debug("Waiting until named pipe #{sv_dir_name}/supervise/ok exists.") - until ::FileTest.pipe?("#{sv_dir_name}/supervise/ok") do + until ::FileTest.pipe?("#{sv_dir_name}/supervise/ok") sleep 1 Chef::Log.debug(".") end @@ -196,13 +192,13 @@ define :runit_service, :directory => nil, :only_if => false, :finish_script => f control_cmd = "#{node[:runit][:chpst_bin]} -u #{params[:owner]} #{control_cmd}" end provider Chef::Provider::Service::Simple - supports :restart => true, :status => true + supports restart: true, status: true start_command "#{control_cmd} #{params[:start_command]} #{service_dir_name}" stop_command "#{control_cmd} #{params[:stop_command]} #{service_dir_name}" restart_command "#{control_cmd} #{params[:restart_command]} #{service_dir_name}" status_command "#{control_cmd} #{params[:status_command]} #{service_dir_name}" if params[:run_restart] && omnibus_helper.should_notify?(params[:name]) - subscribes :restart, resources(:template => "#{sv_dir_name}/run"), :delayed + subscribes :restart, resources(template: "#{sv_dir_name}/run"), :delayed end action :nothing end diff --git a/files/gitlab-cookbooks/runit/metadata.rb b/files/gitlab-cookbooks/runit/metadata.rb index b229a0f46960557a8affc0bccb8ba1e34daa9077..16ea48a325af6e1b33f69c42b5200c5e04a1a05a 100644 --- a/files/gitlab-cookbooks/runit/metadata.rb +++ b/files/gitlab-cookbooks/runit/metadata.rb @@ -8,6 +8,6 @@ depends "package" recipe "runit", "Installs and configures runit" -%w{ ubuntu debian gentoo }.each do |os| +%w(ubuntu debian gentoo).each do |os| supports os end