lib/capistrano/tasks/upstart.rake in capistrano-sidekiq-2.1.0 vs lib/capistrano/tasks/upstart.rake in capistrano-sidekiq-2.2.0
- old
+ new
@@ -1,5 +1,7 @@
+# frozen_string_literal: true
+
git_plugin = self
SUPPRESS_FAILURE = %w[|| echo NO_RUNNING_INSTANCE].freeze
namespace :sidekiq do
@@ -41,11 +43,12 @@
desc 'UnInstall upstart sidekiq service'
task :uninstall do
on roles fetch(:sidekiq_roles) do |role|
git_plugin.switch_user(role) do
- execute :rm, '-f', File.join(fetch(:service_unit_path, fetch_upstart_unit_path), fetch(:sidekiq_service_unit_name))
+ execute :rm, '-f',
+ File.join(fetch(:service_unit_path, fetch_upstart_unit_path), fetch(:sidekiq_service_unit_name))
end
end
end
desc 'Generate service_locally'
@@ -56,11 +59,11 @@
end
def fetch_upstart_unit_path
if fetch(:sidekiq_service_unit_user) == :system
# if the path is not standard `set :service_unit_path`
- "/etc/init"
+ '/etc/init'
else
home_dir = backend.capture :pwd
File.join(home_dir, '.config', 'upstart')
end
end
@@ -68,38 +71,34 @@
def compiled_template
search_paths = [
File.expand_path(
File.join(*%w[.. .. .. generators capistrano sidekiq upstart templates sidekiq.conf.erb]),
__FILE__
- ),
+ )
]
template_path = search_paths.detect { |path| File.file?(path) }
template = File.read(template_path)
ERB.new(template).result(binding)
end
def create_upstart_template
ctemplate = compiled_template
upstart_path = fetch(:service_unit_path, fetch_upstart_unit_path)
- if fetch(:sidekiq_service_unit_user) != :system
- backend.execute :mkdir, "-p", upstart_path
- end
+ backend.execute :mkdir, '-p', upstart_path if fetch(:sidekiq_service_unit_user) != :system
conf_filename = "#{fetch :sidekiq_service_unit_name}.conf"
backend.upload!(
StringIO.new(ctemplate),
"/tmp/#{conf_filename}"
)
+ backend.execute :sudo, :mv, "/tmp/#{conf_filename}", "#{upstart_path}/#{conf_filename}"
if fetch(:sidekiq_service_unit_user) == :system
- backend.execute :sudo, :mv, "/tmp/#{conf_filename}", "#{upstart_path}/#{conf_filename}"
- backend.execute :sudo, :initctl, 'reload-configuration'
+ backend.execute :sudo, :initctl, 'reload-configuration'
else
- backend.execute :sudo, :mv, "/tmp/#{conf_filename}", "#{upstart_path}/#{conf_filename}"
- #backend.execute :sudo, :initctl, 'reload-configuration' #TODO
+ # backend.execute :sudo, :initctl, 'reload-configuration' #TODO
end
end
def num_workers
fetch(:sidekiq_upstart_num_workers, nil)
end
-
end