Removed dependency and restored ports

This commit is contained in:
Fabio Salvini 2017-06-08 21:39:52 +02:00
parent c7a9e6ccb5
commit f64408f584
3 changed files with 6 additions and 6 deletions

View File

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

View File

@ -1,7 +1,7 @@
[
{ log_monitor,
[
{logfiles, ["/tmp/lines.log", "/tmp/lines2.log"]},
{logfiles, ["/tmp/lines.log"]},
{email_config,
[
{sender, "me@example.com"},

View File

@ -1,7 +1,6 @@
{erl_opts, [debug_info]}.
{deps, [
{gen_smtp, ".*", {git,"https://github.com/Vagabond/gen_smtp", {tag, "0.12.0"}}},
{erlexec, ".*", {git,"https://github.com/saleyn/erlexec", {tag, "1.6.4"}}}
{gen_smtp, ".*", {git,"https://github.com/Vagabond/gen_smtp", {tag, "0.12.0"}}}
]}.
{relx, [{release, { log_monitor, "0.1.0" },