diff options
author | David Wragg <dpw@lshift.net> | 2010-02-09 16:56:33 +0000 |
---|---|---|
committer | David Wragg <dpw@lshift.net> | 2010-02-09 16:56:33 +0000 |
commit | 0b6b1e91b8b888f0eb1a26bf3ba059506bafb0ef (patch) | |
tree | 04c9eb952468e18380be740c12c4f2ace2fe9538 | |
parent | c2933f3fc23120e1344caa2a862d4ec7c882960e (diff) | |
download | rabbitmq-server-0b6b1e91b8b888f0eb1a26bf3ba059506bafb0ef.tar.gz |
Fix rabbitmq-multi issue with parentheses in pathbug22289
rabbitmq-multi would fail to start rabbitmq-server.bat if the path had
parentheses in the first few characters of a path component (but not
after the few few characters, due to short names being involved; so
cases such as 'Program Files (x86)' do not trigger the issue).
This fix makes rabbitmq-multi run rabbitmq-server.bat indirectly via
cmd.exe, working around the erlang issue from bug20526. So we no
longer need to involve short names, and by sprinkling double quotes in
the right places we can handle parentheses too.
To test this properly you need a path component with both spaces and
parentheses in the first few characters, e.g. "foo ()".
-rw-r--r-- | scripts/rabbitmq-multi.bat | 3 | ||||
-rw-r--r-- | src/rabbit_multi.erl | 27 |
2 files changed, 18 insertions, 12 deletions
diff --git a/scripts/rabbitmq-multi.bat b/scripts/rabbitmq-multi.bat index e5fb8522..d4083cbd 100644 --- a/scripts/rabbitmq-multi.bat +++ b/scripts/rabbitmq-multi.bat @@ -35,7 +35,6 @@ setlocal rem Preserve values that might contain exclamation marks before
rem enabling delayed expansion
set TDP0=%~dp0
-set TSDP0=%~sdp0
set STAR=%*
setlocal enabledelayedexpansion
@@ -58,7 +57,7 @@ if "!RABBITMQ_NODE_IP_ADDRESS!"=="" ( )
set RABBITMQ_PIDS_FILE=!RABBITMQ_BASE!\rabbitmq.pids
-set RABBITMQ_SCRIPT_HOME=!TSDP0!
+set RABBITMQ_SCRIPT_HOME=!TDP0!
if "!RABBITMQ_CONFIG_FILE!"=="" (
set RABBITMQ_CONFIG_FILE=!RABBITMQ_BASE!\rabbitmq
diff --git a/src/rabbit_multi.erl b/src/rabbit_multi.erl index dc642df4..81654f18 100644 --- a/src/rabbit_multi.erl +++ b/src/rabbit_multi.erl @@ -187,7 +187,7 @@ start_node(Node, RpcTimeout) -> io:format("Starting node ~s...~n", [Node]), case rpc:call(Node, os, getpid, []) of {badrpc, _} -> - Port = run_cmd(script_filename()), + Port = run_rabbitmq_server(), Started = wait_for_rabbit_to_start(Node, RpcTimeout, Port), Pid = case rpc:call(Node, os, getpid, []) of {badrpc, _} -> throw(cannot_get_pid); @@ -217,8 +217,22 @@ wait_for_rabbit_to_start(Node, RpcTimeout, Port) -> end end. -run_cmd(FullPath) -> - erlang:open_port({spawn, FullPath}, [nouse_stdio]). +run_rabbitmq_server() -> + with_os([{unix, fun run_rabbitmq_server_unix/0}, + {win32, fun run_rabbitmq_server_win32/0}]). + +run_rabbitmq_server_unix() -> + FullPath = getenv("RABBITMQ_SCRIPT_HOME") ++ "/rabbitmq-server", + erlang:open_port({spawn_executable, FullPath}, + [{arg0, FullPath}, {args, ["-noinput"]}, nouse_stdio]). + +run_rabbitmq_server_win32() -> + Cmd = filename:nativename(os:find_executable("cmd")), + CmdLine = "\"" ++ getenv("RABBITMQ_SCRIPT_HOME") + ++ "\\rabbitmq-server.bat\" -noinput", + erlang:open_port({spawn_executable, Cmd}, + [{arg0, Cmd}, {args, ["/q", "/s", "/c", CmdLine]}, + nouse_stdio, hide]). is_rabbit_running(Node, RpcTimeout) -> case rpc:call(Node, rabbit, status, [], RpcTimeout) of @@ -236,13 +250,6 @@ with_os(Handlers) -> Handler -> Handler() end. -script_filename() -> - ScriptHome = getenv("RABBITMQ_SCRIPT_HOME"), - ScriptName = with_os( - [{unix , fun () -> "rabbitmq-server" end}, - {win32, fun () -> "rabbitmq-server.bat" end}]), - ScriptHome ++ "/" ++ ScriptName ++ " -noinput". - pids_file() -> getenv("RABBITMQ_PIDS_FILE"). write_pids_file(Pids) -> |