summaryrefslogtreecommitdiff
path: root/src/couchdb
diff options
context:
space:
mode:
authorMark Hammond <mhammond@apache.org>2009-12-02 21:44:47 +0000
committerMark Hammond <mhammond@apache.org>2009-12-02 21:44:47 +0000
commitc32443a012dfe90d6872af829e8df9b743010c90 (patch)
treeb910d78be1c6f6b2a139b2f69d1c682be2427c7c /src/couchdb
parent8aca27f80f170598196d16e4e9841fda88ca93e5 (diff)
COUCHDB-588: don't make log noise when an OS process chooses to terminate normally
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@886319 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/couchdb')
-rw-r--r--src/couchdb/couch_external_manager.erl14
-rw-r--r--src/couchdb/couch_external_server.erl1
-rw-r--r--src/couchdb/couch_os_process.erl3
3 files changed, 15 insertions, 3 deletions
diff --git a/src/couchdb/couch_external_manager.erl b/src/couchdb/couch_external_manager.erl
index 810b3d79..7e401389 100644
--- a/src/couchdb/couch_external_manager.erl
+++ b/src/couchdb/couch_external_manager.erl
@@ -37,6 +37,7 @@ config_change("external", UrlName) ->
% gen_server API
init([]) ->
+ process_flag(trap_exit, true),
Handlers = ets:new(couch_external_manager_handlers, [set, private]),
couch_config:register(fun config_change/2),
{ok, Handlers}.
@@ -81,12 +82,19 @@ handle_call({config, UrlName}, _From, Handlers) ->
handle_cast(_Whatever, State) ->
{noreply, State}.
-handle_info({'EXIT', Reason, Pid}, Handlers) ->
- ?LOG_DEBUG("EXTERNAL: Server ~p died. (reason: ~p)", [Pid, Reason]),
+handle_info({'EXIT', Pid, normal}, Handlers) ->
+ ?LOG_INFO("EXTERNAL: Server ~p terminated normally", [Pid]),
+ % The process terminated normally without us asking - Remove Pid from the
+ % handlers table so we don't attempt to reuse it
+ ets:match_delete(Handlers, {'_', Pid}),
+ {noreply, Handlers};
+
+handle_info({'EXIT', Pid, Reason}, Handlers) ->
+ ?LOG_INFO("EXTERNAL: Server ~p died. (reason: ~p)", [Pid, Reason]),
% Remove Pid from the handlers table so we don't try closing
% it a second time in terminate/2.
ets:match_delete(Handlers, {'_', Pid}),
- {stop, Handlers}.
+ {stop, normal, Handlers}.
code_change(_OldVsn, State, _Extra) ->
{ok, State}.
diff --git a/src/couchdb/couch_external_server.erl b/src/couchdb/couch_external_server.erl
index 8e632510..8e495320 100644
--- a/src/couchdb/couch_external_server.erl
+++ b/src/couchdb/couch_external_server.erl
@@ -34,6 +34,7 @@ execute(Pid, JsonReq) ->
init([Name, Command]) ->
?LOG_INFO("EXTERNAL: Starting process for: ~s", [Name]),
?LOG_INFO("COMMAND: ~s", [Command]),
+ process_flag(trap_exit, true),
Timeout = list_to_integer(couch_config:get("couchdb", "os_process_timeout",
"5000")),
{ok, Pid} = couch_os_process:start_link(Command, [{timeout, Timeout}]),
diff --git a/src/couchdb/couch_os_process.erl b/src/couchdb/couch_os_process.erl
index 244a59f5..72b715c3 100644
--- a/src/couchdb/couch_os_process.erl
+++ b/src/couchdb/couch_os_process.erl
@@ -162,6 +162,9 @@ handle_cast(Msg, OsProc) ->
?LOG_DEBUG("OS Proc: Unknown cast: ~p", [Msg]),
{noreply, OsProc}.
+handle_info({Port, {exit_status, 0}}, #os_proc{port=Port}=OsProc) ->
+ ?LOG_INFO("OS Process terminated normally", []),
+ {stop, normal, OsProc};
handle_info({Port, {exit_status, Status}}, #os_proc{port=Port}=OsProc) ->
?LOG_ERROR("OS Process died with status: ~p", [Status]),
{stop, {exit_status, Status}, OsProc};