Revision 373538353037 () - Diff

Link to this snippet: https://friendpaste.com/5vB0pIKtXXRM0eij296ibX
Embed:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
diff --git a/src/couchdb/couch_os_process.erl b/src/couchdb/couch_os_process.erl
index 3a267be..15e845b 100644
--- a/src/couchdb/couch_os_process.erl
+++ b/src/couchdb/couch_os_process.erl
@@ -20,7 +20,7 @@
-include("couch_db.hrl").
--define(PORT_OPTIONS, [stream, {line, 4096}, binary, exit_status, hide]).
+-define(PORT_OPTIONS, [stream, {line, 1024}, binary, exit_status, hide]).
-record(os_proc,
{command,
@@ -94,7 +94,7 @@ drop_port_messages(Port) ->
% Utility functions for reading and writing
% in custom functions
writeline(OsProc, Data) when is_record(OsProc, os_proc) ->
- port_command(OsProc#os_proc.port, [Data, $\n]).
+ port_command(OsProc#os_proc.port, [Data, $\r, $\n]).
readline(#os_proc{} = OsProc) ->
readline(OsProc, []).
@@ -123,12 +123,12 @@ readline(#os_proc{port = Port} = OsProc, Acc) ->
% Standard JSON functions
writejson(OsProc, Data) when is_record(OsProc, os_proc) ->
JsonData = ?JSON_ENCODE(Data),
- ?LOG_DEBUG("OS Process ~p Input :: ~s", [OsProc#os_proc.port, JsonData]),
+ ?LOG_INFO("OS Process ~p Input :: ~s", [OsProc#os_proc.port, JsonData]),
true = writeline(OsProc, JsonData).
readjson(OsProc) when is_record(OsProc, os_proc) ->
Line = iolist_to_binary(readline(OsProc)),
- ?LOG_DEBUG("OS Process ~p Output :: ~s", [OsProc#os_proc.port, Line]),
+ ?LOG_INFO("OS Process ~p Output :: ~s", [OsProc#os_proc.port, Line]),
try
% Don't actually parse the whole JSON. Just try to see if it's
% a command or a doc map/reduce/filter/show/list/update output.
@@ -185,7 +185,7 @@ init([Command, Options, PortOptions]) ->
},
KillCmd = iolist_to_binary(readline(BaseProc)),
Pid = self(),
- ?LOG_DEBUG("OS Process Start :: ~p", [BaseProc#os_proc.port]),
+ ?LOG_INFO("OS Process Start :: ~p", [BaseProc#os_proc.port]),
spawn(fun() ->
% this ensure the real os process is killed when this process dies.
erlang:monitor(process, Pid),
@@ -231,20 +231,20 @@ handle_cast({send, Data}, #os_proc{writer=Writer}=OsProc) ->
{noreply, OsProc}
catch
throw:OsError ->
- ?LOG_ERROR("Failed sending data: ~p -> ~p", [Data, OsError]),
+ ?LOG_INFO("Failed sending data: ~p -> ~p", [Data, OsError]),
{stop, normal, OsProc}
end;
handle_cast(stop, OsProc) ->
{stop, normal, OsProc};
handle_cast(Msg, OsProc) ->
- ?LOG_DEBUG("OS Proc: Unknown cast: ~p", [Msg]),
+ ?LOG_INFO("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]),
+ ?LOG_INFO("OS Process died with status: ~p", [Status]),
{stop, {exit_status, Status}, OsProc}.
code_change(_OldVsn, State, _Extra) ->