From 3266c66fc4e306fe888979a7cd44b190db456f6d Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Sat, 6 Jun 2020 12:55:02 +1000 Subject: [PATCH] updated fserv to fit the new (and next) service system --- service/fserv.lua | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/service/fserv.lua b/service/fserv.lua index 4d08170..1944679 100644 --- a/service/fserv.lua +++ b/service/fserv.lua @@ -3,12 +3,14 @@ local serial = require "serialization" local cfg = {["path"]="/boot/srv/frequest",["port"]=70} -f=io.open("/boot/cfg/fserv.cfg","rb") -if f then - local ncfg = serial.unserialize(f:read("*a")) - f:close() - for k,v in pairs(ncfg) do - cfg[k] = v +local function loadConfig(cfgpath) + local f=io.open(cfgpath or "/boot/cfg/fserv.cfg","rb") + if f then + local ncfg = serial.unserialize(f:read("*a")) + f:close() + for k,v in pairs(ncfg) do + cfg[k] = v + end end end @@ -90,6 +92,15 @@ local function socketHandler(socket) end end -while true do - os.spawn(socketHandler(minitel.listen(70)),"fserv worker process") +local function fileServer() + while true do + os.spawn(socketHandler(minitel.listen(70)),"fserv worker process") + end end + +function start(cfgpath) + loadConfig(cfgpath) + return os.spawn(fileServer,"fserv") +end + +return {start=start}