Compare commits
4 Commits
77c69f651b
...
0993182839
Author | SHA1 | Date | |
---|---|---|---|
0993182839 | |||
1c252126e8 | |||
1f97e90066 | |||
7b8c532141 |
@ -1,3 +0,0 @@
|
||||
getty.lua
|
||||
fsmanager.lua
|
||||
minitel.lua
|
11
lib/rc.lua
11
lib/rc.lua
@ -1,6 +1,7 @@
|
||||
local serial = require "serialization"
|
||||
|
||||
local rc = {}
|
||||
rc.pids = {}
|
||||
local service = {}
|
||||
local cfg = {}
|
||||
cfg.enabled = {}
|
||||
@ -37,12 +38,20 @@ end
|
||||
function rc.stop(name,...)
|
||||
if not service[name] then return false, "service not found" end
|
||||
service[name].stop(...)
|
||||
coroutine.yield()
|
||||
if rc.pids[name] then
|
||||
os.kill(rc.pids[name])
|
||||
end
|
||||
rc.pids[name] = nil
|
||||
end
|
||||
|
||||
function rc.start(name,...)
|
||||
rc.load(name)
|
||||
if not service[name] then return false, "service not found" end
|
||||
return service[name].start(...)
|
||||
local rv = {service[name].start(...)}
|
||||
if type(rv[1]) == "number" then
|
||||
rc.pids[name] = rv[1]
|
||||
end
|
||||
end
|
||||
|
||||
function rc.restart(name)
|
||||
|
@ -12,7 +12,7 @@ end
|
||||
|
||||
local function formatValue(v)
|
||||
if type(v) == "table" then
|
||||
local w, rs = pcall(serial.serialize,v)
|
||||
local w, rs = pcall(serial.serialize,v,true)
|
||||
if w then return rs end
|
||||
end
|
||||
return tostring(v)
|
||||
|
@ -55,10 +55,10 @@ local function allocate()
|
||||
end
|
||||
|
||||
function start()
|
||||
basepid = os.spawn(function()
|
||||
scan()
|
||||
allocate()
|
||||
dprint("screens ready")
|
||||
basepid = os.spawn(function()
|
||||
while true do
|
||||
coroutine.yield()
|
||||
for k,v in pairs(pids) do
|
||||
|
Loading…
Reference in New Issue
Block a user