diff options
author | Simon MacMullen <simon@rabbitmq.com> | 2013-12-05 16:01:35 +0000 |
---|---|---|
committer | Simon MacMullen <simon@rabbitmq.com> | 2013-12-05 16:01:35 +0000 |
commit | 80fd513bda062aae194e07f5795dcbf286d7a4b0 (patch) | |
tree | ecf7f8b28c8c00c9aac8bc664512551ca40a4bd7 | |
parent | 9d7ca484130d69d6755fda31f83b061974055e33 (diff) | |
parent | 077be866a983102148b508cf548f5da997fd32d1 (diff) | |
download | rabbitmq-server-80fd513bda062aae194e07f5795dcbf286d7a4b0.tar.gz |
Merge bug22525
-rw-r--r-- | ebin/rabbit_app.in | 1 | ||||
-rw-r--r-- | src/rabbit.erl | 32 | ||||
-rw-r--r-- | src/rabbit_tests.erl | 6 | ||||
-rw-r--r-- | src/rabbit_upgrade.erl | 9 |
4 files changed, 32 insertions, 16 deletions
diff --git a/ebin/rabbit_app.in b/ebin/rabbit_app.in index 0254bb21..29f06e79 100644 --- a/ebin/rabbit_app.in +++ b/ebin/rabbit_app.in @@ -53,6 +53,7 @@ {nodelay, true}, {linger, {true, 0}}, {exit_on_close, false}]}, + {halt_on_upgrade_failure, true}, {hipe_compile, false}, %% see bug 24513 for how this list was created {hipe_modules, diff --git a/src/rabbit.erl b/src/rabbit.erl index 1b7fe6da..045c5d58 100644 --- a/src/rabbit.erl +++ b/src/rabbit.erl @@ -347,19 +347,25 @@ handle_app_error(App, Reason) -> start_it(StartFun) -> Marker = spawn_link(fun() -> receive stop -> ok end end), - register(rabbit_boot, Marker), - try - StartFun() - catch - throw:{could_not_start, _App, _Reason}=Err -> - boot_error(Err, not_available); - _:Reason -> - boot_error(Reason, erlang:get_stacktrace()) - after - unlink(Marker), - Marker ! stop, - %% give the error loggers some time to catch up - timer:sleep(100) + case catch register(rabbit_boot, Marker) of + true -> try + case is_running() of + true -> ok; + false -> StartFun() + end + catch + throw:{could_not_start, _App, _Reason}=Err -> + boot_error(Err, not_available); + _:Reason -> + boot_error(Reason, erlang:get_stacktrace()) + after + unlink(Marker), + Marker ! stop, + %% give the error loggers some time to catch up + timer:sleep(100) + end; + _ -> unlink(Marker), + Marker ! stop end. stop() -> diff --git a/src/rabbit_tests.erl b/src/rabbit_tests.erl index 76421d1a..5fe319d3 100644 --- a/src/rabbit_tests.erl +++ b/src/rabbit_tests.erl @@ -808,6 +808,7 @@ test_log_management_during_startup() -> %% start application with logging to non-existing directory TmpLog = "/tmp/rabbit-tests/test.log", delete_file(TmpLog), + ok = control_action(stop_app, []), ok = application:set_env(rabbit, error_logger, {file, TmpLog}), ok = delete_log_handlers([rabbit_error_logger_file_h]), @@ -816,6 +817,7 @@ test_log_management_during_startup() -> %% start application with logging to directory with no %% write permissions + ok = control_action(stop_app, []), TmpDir = "/tmp/rabbit-tests", ok = set_permissions(TmpDir, 8#00400), ok = delete_log_handlers([rabbit_error_logger_file_h]), @@ -830,6 +832,7 @@ test_log_management_during_startup() -> %% start application with logging to a subdirectory which %% parent directory has no write permissions + ok = control_action(stop_app, []), TmpTestDir = "/tmp/rabbit-tests/no-permission/test/log", ok = application:set_env(rabbit, error_logger, {file, TmpTestDir}), ok = add_log_handlers([{error_logger_file_h, MainLog}]), @@ -849,12 +852,13 @@ test_log_management_during_startup() -> %% start application with standard error_logger_file_h %% handler not installed + ok = control_action(stop_app, []), ok = application:set_env(rabbit, error_logger, {file, MainLog}), ok = control_action(start_app, []), - ok = control_action(stop_app, []), %% start application with standard sasl handler not installed %% and rabbit main log handler installed correctly + ok = control_action(stop_app, []), ok = delete_log_handlers([rabbit_sasl_report_file_h]), ok = control_action(start_app, []), passed. diff --git a/src/rabbit_upgrade.erl b/src/rabbit_upgrade.erl index 1047b823..c1f142d7 100644 --- a/src/rabbit_upgrade.erl +++ b/src/rabbit_upgrade.erl @@ -191,9 +191,14 @@ die(Msg, Args) -> %% straight out into do_boot, generating an erl_crash.dump %% and displaying any error message in a confusing way. error_logger:error_msg(Msg, Args), - io:format("~n~n****~n~n" ++ Msg ++ "~n~n****~n~n~n", Args), + Str = rabbit_misc:format( + "~n~n****~n~n" ++ Msg ++ "~n~n****~n~n~n", Args), + io:format(Str), error_logger:logfile(close), - halt(1). + case application:get_env(rabbit, halt_on_upgrade_failure) of + {ok, false} -> throw({upgrade_error, Str}); + _ -> halt(1) %% i.e. true or undefined + end. primary_upgrade(Upgrades, Nodes) -> Others = Nodes -- [node()], |