Skip to content

Commit 8d7f637

Browse files
authored
Merge pull request #2 from lubosch/main
Fix system user
2 parents 02160c8 + 9520d9a commit 8d7f637

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

lib/capistrano/solid_queue.rb

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,25 @@ def register_hooks
2525
end
2626

2727
def execute_systemd(*args, raise_on_non_zero_exit: true)
28-
command = ["/bin/systemctl", "--user"] + args
29-
backend.execute(*command, raise_on_non_zero_exit: raise_on_non_zero_exit)
28+
sudo_if_needed(*systemd_command(*args), raise_on_non_zero_exit: true)
29+
end
30+
31+
def sudo_if_needed(*command, raise_on_non_zero_exit: true)
32+
if fetch(:solid_queue_systemctl_user) == :system
33+
backend.sudo command.map(&:to_s).join(" ")
34+
else
35+
backend.execute(*command, raise_on_non_zero_exit: raise_on_non_zero_exit)
36+
end
37+
end
38+
39+
def systemd_command(*args)
40+
command = ['/bin/systemctl']
41+
42+
unless fetch(:solid_queue_systemctl_user) == :system
43+
command << "--user"
44+
end
45+
46+
command + args
3047
end
3148

3249
def fetch_systemd_unit_path

lib/capistrano/solid_queue/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
module Capistrano
44
module SolidQueue
5-
VERSION = "0.1.0"
5+
VERSION = "0.1.1"
66
end
77
end

0 commit comments

Comments
 (0)