Skip to content
Snippets Groups Projects
Commit 9f594b12 authored by Balasankar C's avatar Balasankar C Committed by Marin Jankovski
Browse files

Make runit recipes Rubocop friendly

parent bb144b25
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -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
Loading
Loading
@@ -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"
Loading
Loading
@@ -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)
Loading
Loading
@@ -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]
Loading
Loading
@@ -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
 
Loading
Loading
@@ -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
 
Loading
Loading
@@ -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
Loading
Loading
@@ -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
Loading
Loading
@@ -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
 
Loading
Loading
@@ -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
Loading
Loading
@@ -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
Loading
Loading
Loading
Loading
@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment