summaryrefslogtreecommitdiff
path: root/src/rabbit.erl
diff options
context:
space:
mode:
authorLuke Bakken <lbakken@pivotal.io>2018-02-02 13:00:51 -0800
committerLuke Bakken <lbakken@pivotal.io>2018-02-02 13:00:51 -0800
commit0715e8f45e7e58b5f02b9d9cddd852d29861de14 (patch)
tree23124b3a750ae0b6490f305d90f4b846b6a2506b /src/rabbit.erl
parent15a7641efc54989cf258587481b8cbf91543c490 (diff)
downloadrabbitmq-server-git-0715e8f45e7e58b5f02b9d9cddd852d29861de14.tar.gz
Find systemd unit via ps
Also terminate systemctl args with `--` in case the unit name starts with a dash Fixes #1187
Diffstat (limited to 'src/rabbit.erl')
-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);