Removed dependency and restored ports
This commit is contained in:
@@ -6,14 +6,15 @@ start(MonitorPid, File) ->
|
||||
|
||||
init(MonitorPid, File) ->
|
||||
Cmd = "/usr/bin/tail -n0 --follow=name " ++ File,
|
||||
Port = open_port({spawn, Cmd}, [stderr_to_stdout, {line, 256}, exit_status, binary]),
|
||||
Port = open_port({spawn, Cmd}, [stderr_to_stdout, exit_status, binary]),
|
||||
loop(MonitorPid, Port).
|
||||
|
||||
loop(MonitorPid, Port) ->
|
||||
receive
|
||||
{Port, {data, {eol, Bin}}} ->
|
||||
%% io:format("~s~n", [iolist_to_binary(Bin)]),
|
||||
Text = binary_to_list(iolist_to_binary(Bin)),
|
||||
MonitorPid ! {log_line, Text},
|
||||
loop(MonitorPid, Port)
|
||||
loop(MonitorPid, Port);
|
||||
{Port, {exit_status, _Status}} ->
|
||||
io:format("Watcher terminated~n")
|
||||
end.
|
||||
|
||||
Reference in New Issue
Block a user