Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes systemd rake tasks with multi processes #302

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions lib/capistrano/tasks/systemd.rake
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ namespace :sidekiq do
task command do
on roles fetch(:sidekiq_roles) do |role|
git_plugin.switch_user(role) do
git_plugin.systemctl_command(command)
git_plugin.process_block do |process|
git_plugin.systemctl_command(command, process: process)
end
end
end
end
Expand All @@ -23,8 +25,8 @@ namespace :sidekiq do
task :restart do
on roles fetch(:sidekiq_roles) do |role|
git_plugin.switch_user(role) do
git_plugin.quiet_sidekiq
git_plugin.process_block do |process|
git_plugin.quiet_sidekiq(process: process)
start_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)
running = nil

Expand Down Expand Up @@ -68,7 +70,9 @@ namespace :sidekiq do
task :quiet do
on roles fetch(:sidekiq_roles) do |role|
git_plugin.switch_user(role) do
git_plugin.quiet_sidekiq
git_plugin.process_block do |process|
git_plugin.quiet_sidekiq(process: process)
end
end
end
end
Expand All @@ -83,7 +87,10 @@ namespace :sidekiq do
git_plugin.create_systemd_config_symlink(process)
end
end
git_plugin.systemctl_command(:enable)

git_plugin.process_block do |process|
git_plugin.systemctl_command(:enable, process: process)
end

if fetch(:sidekiq_service_unit_user) != :system && fetch(:sidekiq_enable_lingering)
execute :loginctl, 'enable-linger', fetch(:sidekiq_lingering_user)
Expand All @@ -96,8 +103,11 @@ namespace :sidekiq do
task :uninstall do
on roles fetch(:sidekiq_roles) do |role|
git_plugin.switch_user(role) do
git_plugin.systemctl_command(:stop)
git_plugin.systemctl_command(:disable)
git_plugin.process_block do |process|
git_plugin.systemctl_command(:stop, process: process)
git_plugin.systemctl_command(:disable, process: process)
end

if git_plugin.config_per_process?
git_plugin.process_block do |process|
git_plugin.delete_systemd_config_symlink(process)
Expand Down Expand Up @@ -217,8 +227,8 @@ namespace :sidekiq do
backend.execute(*execute_array, raise_on_non_zero_exit: false)
end

def quiet_sidekiq
systemctl_command(:kill, '-s', :TSTP)
def quiet_sidekiq(process: nil)
systemctl_command(:kill, '-s', :TSTP, process: process)
end

def switch_user(role, &block)
Expand Down