Merge bug22525

This commit is contained in:
Simon MacMullen 2013-12-05 16:01:35 +00:00
commit 160092e8ea
4 changed files with 32 additions and 16 deletions

View File

@ -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,

View File

@ -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() ->

View File

@ -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.

View File

@ -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()],