mirror of
https://github.com/BioArchLinux/Rosa.git
synced 2025-03-10 12:02:43 +00:00
add: monitor
This commit is contained in:
parent
d19f7e6d82
commit
ded7b7183f
2 changed files with 38 additions and 0 deletions
8
rosa.service
Normal file
8
rosa.service
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
[Unit]
|
||||||
|
Description=Rosa API generator
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
ExecStart=/usr/bin/lua /usr/share/lilac/Rosa/rosa.watch.lua
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
|
30
rosa.watch.lua
Normal file
30
rosa.watch.lua
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
#!/usr/bin/lua
|
||||||
|
|
||||||
|
local lfs = require("lfs")
|
||||||
|
|
||||||
|
local rosalua = "/usr/share/lilac/Rosa/rosa.lua"
|
||||||
|
local filepath = "/usr/share/lilac/Repo/x86_64/bioarchlinux.files" -- what I watch
|
||||||
|
local last_modified = nil
|
||||||
|
local attr = lfs.attributes(filepath)
|
||||||
|
last_modified = attr.modification
|
||||||
|
|
||||||
|
--watch file--
|
||||||
|
local function check_changes()
|
||||||
|
-- current time
|
||||||
|
local attr = lfs.attributes(filepath)
|
||||||
|
local current_modified = attr.modification
|
||||||
|
-- if different
|
||||||
|
if current_modified ~= last_modified then
|
||||||
|
-- update info
|
||||||
|
last_modified = current_modified
|
||||||
|
-- run script
|
||||||
|
print("Executing Rosa Lua")
|
||||||
|
dofile(rosalua)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--2 min sync--
|
||||||
|
while true do
|
||||||
|
check_changes()
|
||||||
|
os.execute("sleep " .. tonumber(120)) -- 120s = 2min
|
||||||
|
end
|
Loading…
Add table
Reference in a new issue