diff options
| author | ruki <[email protected]> | 2022-04-10 21:42:06 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2022-04-10 21:42:06 +0800 |
| commit | 275486b26f621e448e70fedcaa1cbbd515c4b931 (patch) | |
| tree | 9d8374ccaef9654633c3b1bd24fafd4ee0f96025 | |
| parent | c3319aeb502825434e3055e27e4593e817e3485c (diff) | |
remove session cache
| -rw-r--r-- | xmake/modules/private/service/config.lua | 6 | ||||
| -rw-r--r-- | xmake/modules/private/service/remote_build/server.lua | 8 | ||||
| -rw-r--r-- | xmake/modules/private/service/remote_build/session.lua | 11 |
3 files changed, 23 insertions, 2 deletions
diff --git a/xmake/modules/private/service/config.lua b/xmake/modules/private/service/config.lua index bbc39c465..dddda6656 100644 --- a/xmake/modules/private/service/config.lua +++ b/xmake/modules/private/service/config.lua @@ -25,11 +25,13 @@ import("core.base.global") function _generate_configfile() local filepath = configfile() assert(not _g.configs and not os.isfile(filepath)) + local servicedir = path.join(global.directory(), "service") local configs = { - logfile = path.join(global.directory(), "service", "logs.txt"), + logfile = path.join(servicedir, "logs.txt"), remote_build = { server = { - listen = "127.0.0.1:90091" + listen = "127.0.0.1:90091", + workdir = path.join(servicedir, "remote_build") }, client = { connect = "127.0.0.1:90091" diff --git a/xmake/modules/private/service/remote_build/server.lua b/xmake/modules/private/service/remote_build/server.lua index dc7cb67d3..5ad0c2b19 100644 --- a/xmake/modules/private/service/remote_build/server.lua +++ b/xmake/modules/private/service/remote_build/server.lua @@ -98,6 +98,14 @@ end -- close session function remote_build_server:_session_close(session_id) + -- remove the session caches + local session = self:_session(session_id) + if session then + local workdir = session:workdir() + if workdir then + os.tryrm(workdir) + end + end self._SESSIONS[session_id] = nil end diff --git a/xmake/modules/private/service/remote_build/session.lua b/xmake/modules/private/service/remote_build/session.lua index df7e1f837..0c28e2406 100644 --- a/xmake/modules/private/service/remote_build/session.lua +++ b/xmake/modules/private/service/remote_build/session.lua @@ -20,6 +20,8 @@ -- imports import("core.base.object") +import("core.base.global") +import("private.service.config") -- define module local session = session or object() @@ -34,6 +36,15 @@ function session:id() return self._ID end +-- get work directory +function session:workdir() + local workdir = config.get("remote_build.server.workdir") + if not workdir then + workdir = path.join(global.directory(), "service", "remote_build") + end + return path.join(workdir, "sessons", self:id()) +end + function main(session_id) local instance = session() instance:init(session_id) |
