Skip to content

Commit

Permalink
Make reload also support system mode. (#331) (#331)
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric-Guo authored Sep 3, 2021
1 parent 4a7e801 commit cfdd601
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/capistrano/tasks/systemd.rake
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,17 @@ namespace :puma do
desc 'Reload Puma service via systemd'
task :reload do
on roles(fetch(:puma_role)) do
service_ok = execute("#{fetch(:puma_systemctl_bin)} --user status #{fetch(:puma_service_unit_name)} > /dev/null", raise_on_non_zero_exit: false)
service_ok = if fetch(:puma_systemctl_user) == :system
execute("#{fetch(:puma_systemctl_bin)} status #{fetch(:puma_service_unit_name)} > /dev/null", raise_on_non_zero_exit: false)
else
execute("#{fetch(:puma_systemctl_bin)} --user status #{fetch(:puma_service_unit_name)} > /dev/null", raise_on_non_zero_exit: false)
end
cmd = 'reload'
if !service_ok
cmd = 'restart'
end
if fetch(:puma_systemctl_user) == :system
sudo "#{fetch(:puma_systemctl_bin)} #{cmd} #{fetch(:puma_service_unit_name)}"
sudo "#{fetch(:puma_systemctl_bin)} #{cmd} #{fetch(:puma_service_unit_name)}"
else
execute "#{fetch(:puma_systemctl_bin)}", "--user", cmd, fetch(:puma_service_unit_name)
end
Expand Down

0 comments on commit cfdd601

Please sign in to comment.