Skip to content
Merged
Show file tree
Hide file tree
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
21 changes: 19 additions & 2 deletions lib/capistrano/solid_queue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,25 @@ def register_hooks
end

def execute_systemd(*args, raise_on_non_zero_exit: true)
command = ["/bin/systemctl", "--user"] + args
backend.execute(*command, raise_on_non_zero_exit: raise_on_non_zero_exit)
sudo_if_needed(*systemd_command(*args), raise_on_non_zero_exit: true)
end

def sudo_if_needed(*command, raise_on_non_zero_exit: true)
if fetch(:solid_queue_systemctl_user) == :system
backend.sudo command.map(&:to_s).join(" ")
else
backend.execute(*command, raise_on_non_zero_exit: raise_on_non_zero_exit)
end
end

def systemd_command(*args)
command = ['/bin/systemctl']

unless fetch(:solid_queue_systemctl_user) == :system
command << "--user"
end

command + args
end

def fetch_systemd_unit_path
Expand Down
2 changes: 1 addition & 1 deletion lib/capistrano/solid_queue/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

module Capistrano
module SolidQueue
VERSION = "0.1.0"
VERSION = "0.1.1"
end
end
Loading