Skip to content

Commit 5f7d621

Browse files
Merge pull request #1494 from rabbitmq/rabbitmq-server-1187
Find systemd unit via ps
2 parents 46cf04b + 0715e8f commit 5f7d621

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/rabbit.erl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,8 @@ sd_notify_socat(Unit) ->
401401
end.
402402

403403
sd_current_unit() ->
404-
case catch re:run(os:cmd("systemctl status " ++ os:getpid()), "([-.@0-9a-zA-Z]+)", [unicode, {capture, all_but_first, list}]) of
404+
CmdOut = os:cmd("ps -o unit= -p " ++ os:getpid()),
405+
case catch re:run(CmdOut, "([-.@0-9a-zA-Z]+)", [unicode, {capture, all_but_first, list}]) of
405406
{'EXIT', _} ->
406407
error;
407408
{match, [Unit]} ->
@@ -424,7 +425,7 @@ sd_wait_activation(_, _, 0) ->
424425
io:format(standard_error, "Service still in 'activating' state, bailing out~n", []),
425426
false;
426427
sd_wait_activation(Port, Unit, AttemptsLeft) ->
427-
case os:cmd("systemctl show --property=ActiveState " ++ Unit) of
428+
case os:cmd("systemctl show --property=ActiveState -- '" ++ Unit ++ "'") of
428429
"ActiveState=activating\n" ->
429430
timer:sleep(1000),
430431
sd_wait_activation(Port, Unit, AttemptsLeft - 1);

0 commit comments

Comments
 (0)