Skip to content

Commit

Permalink
restart if systemd service is not running
Browse files Browse the repository at this point in the history
  • Loading branch information
mksvdmtr committed Jun 7, 2021
1 parent 187a363 commit e92af03
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/capistrano/tasks/systemd.rake
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,15 @@ 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)
cmd = 'reload'
if !service_ok
cmd = 'restart'
end
if fetch(:puma_systemctl_user) == :system
sudo "#{fetch(:puma_systemctl_bin)} reload #{fetch(:puma_service_unit_name)}"
sudo "#{fetch(:puma_systemctl_bin)} #{cmd} #{fetch(:puma_service_unit_name)}"
else
execute "#{fetch(:puma_systemctl_bin)}", "--user", "reload", fetch(:puma_service_unit_name)
execute "#{fetch(:puma_systemctl_bin)}", "--user", cmd, fetch(:puma_service_unit_name)
end
end
end
Expand Down

0 comments on commit e92af03

Please sign in to comment.