summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Klishin <michael@novemberain.com>2018-02-07 08:59:38 +0100
committerGitHub <noreply@github.com>2018-02-07 08:59:38 +0100
commit5f7d62113b312af732c1db98089ab5888db960dd (patch)
tree08f5789dbdf4ffccaf406126d1444b48e5784ecd
parent46cf04ba7ee1c4b3f9cdcbebb889de557c248882 (diff)
parent0715e8f45e7e58b5f02b9d9cddd852d29861de14 (diff)
downloadrabbitmq-server-git-5f7d62113b312af732c1db98089ab5888db960dd.tar.gz
Merge pull request #1494 from rabbitmq/rabbitmq-server-1187
Find systemd unit via ps
-rw-r--r--src/rabbit.erl5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/rabbit.erl b/src/rabbit.erl
index 745ba4631d..37b33bd8a4 100644
--- a/src/rabbit.erl
+++ b/src/rabbit.erl
@@ -401,7 +401,8 @@ sd_notify_socat(Unit) ->
end.
sd_current_unit() ->
- case catch re:run(os:cmd("systemctl status " ++ os:getpid()), "([-.@0-9a-zA-Z]+)", [unicode, {capture, all_but_first, list}]) of
+ CmdOut = os:cmd("ps -o unit= -p " ++ os:getpid()),
+ case catch re:run(CmdOut, "([-.@0-9a-zA-Z]+)", [unicode, {capture, all_but_first, list}]) of
{'EXIT', _} ->
error;
{match, [Unit]} ->
@@ -424,7 +425,7 @@ sd_wait_activation(_, _, 0) ->
io:format(standard_error, "Service still in 'activating' state, bailing out~n", []),
false;
sd_wait_activation(Port, Unit, AttemptsLeft) ->
- case os:cmd("systemctl show --property=ActiveState " ++ Unit) of
+ case os:cmd("systemctl show --property=ActiveState -- '" ++ Unit ++ "'") of
"ActiveState=activating\n" ->
timer:sleep(1000),
sd_wait_activation(Port, Unit, AttemptsLeft - 1);