mirror of
https://git.shadowkat.net/izaya/OC-PsychOS2.git
synced 2024-11-22 03:54:20 -05:00
made rc enforce the new service semantics
This commit is contained in:
parent
417856ebd6
commit
d40ce731ef
17
lib/rc.lua
17
lib/rc.lua
@ -1,6 +1,7 @@
|
|||||||
local serial = require "serialization"
|
local serial = require "serialization"
|
||||||
|
|
||||||
local rc = {}
|
local rc = {}
|
||||||
|
rc.paths = "/boot/service\n/pkg/service"
|
||||||
rc.pids = {}
|
rc.pids = {}
|
||||||
local service = {}
|
local service = {}
|
||||||
local cfg = {}
|
local cfg = {}
|
||||||
@ -23,6 +24,21 @@ local function saveConfig()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function rc.load(name,force) -- string boolean -- table -- Attempts to load service *name*, and if *force* is true, replaces the current instance.
|
function rc.load(name,force) -- string boolean -- table -- Attempts to load service *name*, and if *force* is true, replaces the current instance.
|
||||||
|
if not package.loaded[name] or force then
|
||||||
|
for d in rc.paths:gmatch("[^\n]+") do
|
||||||
|
if fs.exists(d.."/"..name..".lua") then
|
||||||
|
service[name] = runfile(d.."/"..name..".lua")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if service[name] then
|
||||||
|
return service[name]
|
||||||
|
end
|
||||||
|
return false, "unable to load service "..name
|
||||||
|
end
|
||||||
|
|
||||||
|
--[[
|
||||||
|
function rc.load(name,force) -- string boolean -- table -- Attempts to load service *name*, and if *force* is true, replaces the current instance.
|
||||||
if force then
|
if force then
|
||||||
rc.stop(name)
|
rc.stop(name)
|
||||||
service[name] = nil
|
service[name] = nil
|
||||||
@ -39,6 +55,7 @@ function rc.load(name,force) -- string boolean -- table -- Attempts to load serv
|
|||||||
f:close()
|
f:close()
|
||||||
return res
|
return res
|
||||||
end
|
end
|
||||||
|
]]
|
||||||
|
|
||||||
function rc.stop(name,...) -- string -- boolean string -- Stops service *name*, supplying *...* to the stop function. Returns false and a reason if this fails.
|
function rc.stop(name,...) -- string -- boolean string -- Stops service *name*, supplying *...* to the stop function. Returns false and a reason if this fails.
|
||||||
if not service[name] then return false, "service not found" end
|
if not service[name] then return false, "service not found" end
|
||||||
|
Loading…
Reference in New Issue
Block a user