lsyncd/examples/lalarm.lua

27 lines
717 B
Lua
Raw Normal View History

2010-11-29 20:32:54 +00:00
-----
-- User configuration file for lsyncd.
--
-- While this example does not do anything it shows
-- how user custom alarms can be now. It will log
-- "Beep!" every 5 seconds.
--
2010-11-30 23:14:17 +00:00
settings.nodaemon = true
2010-11-29 20:32:54 +00:00
2010-11-30 23:14:17 +00:00
local function noAction (inlet)
-- just discard any events that happes in source dir.
inlet.discardEvent(inlet.getEvent())
end
2010-11-29 20:32:54 +00:00
2010-11-30 23:14:17 +00:00
-----
-- Adds a watch to some not so large directory for this example.
local in1 = sync{source="/usr/local/etc/", action = noAction }
2010-11-30 17:08:15 +00:00
2010-11-30 23:14:17 +00:00
local function myAlarm(timestamp, extra)
log("Normal", extra.message)
spawn(extra.inlet.createBlanketEvent(), "/bin/echo", extra.message)
alarm(timestamp + 5, myAlarm, extra)
end
2010-11-29 20:32:54 +00:00
2010-11-30 23:14:17 +00:00
alarm(now() + 5, myAlarm, {inlet = in1, message = "Beep"})
2010-11-29 20:32:54 +00:00