ryo33 / fwatch-ex

A file watcher for Elixir language
MIT License
4 stars 0 forks source link

Not getting any sort of events out #2

Open ciokan opened 8 years ago

ciokan commented 8 years ago

Just used the code from your README with a watch on /var/log/syslog. No events are being sent out

require Logger

defmodule Fail2ban.Watcher do
    use GenServer

    def start_link(name \\ nil) do
        GenServer.start_link(__MODULE__, nil, [name: name])
    end

    def init(state) do
        watch()
        {:ok, state}
    end

    def watch do
        Logger.info "Setting up syslog listener"

        {:ok, receiver_pid} = Fail2ban.Receiver.start_link

        Fwatch.watch_file "/var/log/syslog", fn _path, events ->
            IO.inspect events # Nothing printed upon modifying syslog
        end
    end
end
ryo33 commented 8 years ago

I'll add the new inferface to solve this problem like this:

{:ok, pid} = Fwatch.start_link(:syslog_watcher, "/var/log")
Fwatch.watch_file(pid, "/var/log/syslog", callback)

But this doesn't work on the current version(0.9.2) of fs. Why Is :fs.start_link/2 Undefined?

ryo33 commented 8 years ago

@ciokan I added the API. Since it can not be published to hex.pm yet it can be used by specifying {:fwatch, github: "ryo33/fwatch", branch: "master"}.