diff options
author | John Christopher Anderson <jchris@apache.org> | 2009-02-01 02:43:00 +0000 |
---|---|---|
committer | John Christopher Anderson <jchris@apache.org> | 2009-02-01 02:43:00 +0000 |
commit | 6d79547b25282a7f75221152e87a310d6bbc7a2f (patch) | |
tree | 13b9d39c33ae328b7170b88621078c0f0601da7e /src/couchdb/couch_external_server.erl | |
parent | 02e15395d8f4fa43e135e48d321c89cc9622a1a8 (diff) |
via davisp: external server launches on request to avoid runaway errors.
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@739681 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/couchdb/couch_external_server.erl')
-rw-r--r-- | src/couchdb/couch_external_server.erl | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/src/couchdb/couch_external_server.erl b/src/couchdb/couch_external_server.erl index 49a31c06..08cb4d6b 100644 --- a/src/couchdb/couch_external_server.erl +++ b/src/couchdb/couch_external_server.erl @@ -16,8 +16,6 @@ -export([start_link/2, stop/1, execute/2]). -export([init/1, terminate/2, handle_call/3, handle_cast/2, handle_info/2, code_change/3]). --define(TIMEOUT, 5000). - -include("couch_db.hrl"). % External API @@ -34,12 +32,12 @@ execute(Pid, JsonReq) -> % Gen Server Handlers init([Name, Command]) -> - ?LOG_INFO("Starting process for: ~s", [Name]), + ?LOG_INFO("EXTERNAL: Starting process for: ~s", [Name]), + ?LOG_INFO("COMMAND: ~s", [Command]), {ok, Pid} = couch_os_process:start_link(Command), {ok, {Name, Command, Pid}}. -terminate(_Reason, {Name, _Command, Pid}) -> - ?LOG_INFO("External Process Terminating: ~p: ~p", [Name, Pid]), +terminate(_Reason, {_Name, _Command, Pid}) -> couch_os_process:stop(Pid), ok. @@ -47,12 +45,13 @@ handle_call({execute, JsonReq}, _From, {Name, Command, Pid}) -> {reply, couch_os_process:prompt(Pid, JsonReq), {Name, Command, Pid}}. handle_info({'EXIT', Pid, Reason}, {Name, Command, Pid}) -> - ?LOG_INFO("EXTERNAL: Restarting process for ~s (reason: ~w)", [Name, Reason]), - {ok, Pid} = couch_os_process:start_link(Command), - {noreply, {Name, Command, Pid}}. + ?LOG_INFO("EXTERNAL: Process for ~s exiting. (reason: ~w)", [Name, Reason]), + {stop, normal, {Name, Command, Pid}}. -handle_cast(stop, State) -> - {stop, normal, State}; +handle_cast(stop, {Name, Command, Pid}) -> + ?LOG_INFO("EXTERNAL: Shutting down ~s", [Name]), + exit(Pid, normal), + {stop, normal, {Name, Command, Pid}}; handle_cast(_Whatever, State) -> {noreply, State}. |