Skip to content

Instantly share code, notes, and snippets.

@Gabrimarin
Last active November 8, 2021 17:46
Show Gist options
  • Save Gabrimarin/ddd8dbc6927995bfc2a2a69f39035a3f to your computer and use it in GitHub Desktop.
Save Gabrimarin/ddd8dbc6927995bfc2a2a69f39035a3f to your computer and use it in GitHub Desktop.
defmodule KV do
def processaMensagem(itm) do
if (elem(itm, 0) == :file_event) do
System.cmd("rsync", ["-r", "path/", "lapada@192.168.201.100:/home/lapada/destino"])
end
end
def receiver() do
receive do
msg -> processaMensagem(msg)
end
KV.receiver()
end
def watch() do
{:ok, pid} = FileSystem.start_link(dirs: ["path"])
FileSystem.subscribe(pid)
KV.receiver()
end
end
KV.watch()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment