summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/debugger.lua20
-rw-r--r--server/main.lua3
-rw-r--r--server/src/log.lua5
3 files changed, 17 insertions, 11 deletions
diff --git a/server/debugger.lua b/server/debugger.lua
index c14cfaea..76266313 100644
--- a/server/debugger.lua
+++ b/server/debugger.lua
@@ -34,18 +34,22 @@ table.sort(luaDebugs, function (a, b)
end)
local debugPath = extensionPath / luaDebugs[1]
-local cpath = "runtime/win64/lua54/?.dll"
-local path = "script/?.lua"
+local cpath = "/runtime/win64/lua54/?.dll"
+local path = "/script/?.lua"
-package.cpath = package.cpath .. ';' .. (debugPath / cpath):string()
+package.cpath = package.cpath .. ';' .. debugPath:string() .. cpath
local function tryDebugger()
local rdebug = require "remotedebug"
- local entry = package.searchpath('start_debug', (debugPath / path):string())
- local dbg = loadfile(entry)(rdebug, debugPath:string() .. '/', path, cpath)
- local port = "11411"
- dbg:start("listen:127.0.0.1:" .. port, true)
- log.debug('Debugger startup, listen port:', port)
+ local entry = package.searchpath('start_debug', debugPath:string() .. path)
+ local root = debugPath:string()
+ local pid = "11411"
+ local addr = ("@%s/runtime/tmp/pid_%s.tmp"):format(root, pid)
+ local dbg = loadfile(entry)(rdebug, root, path, cpath)
+ debug.getregistry()["lua-debug"] = dbg
+ dbg:start(addr, true)
+ log.debug('Debugger startup, listen port:', pid)
+ log.debug('Args:', addr, rdebug, root, path, cpath)
end
xpcall(tryDebugger, log.debug)
diff --git a/server/main.lua b/server/main.lua
index c9b51239..d1673836 100644
--- a/server/main.lua
+++ b/server/main.lua
@@ -19,9 +19,10 @@ collectgarbage("setstepmul", 1000)
log = require 'log'
log.init(ROOT, ROOT / 'log' / 'service.log')
log.info('Lua Lsp startup, root: ', ROOT)
+log.debug('ROOT:', ROOT:string())
ac = {}
---xpcall(dofile, log.debug, rootPath .. 'debugger.lua')
+xpcall(dofile, log.debug, rootPath .. 'debugger.lua')
require 'utility'
require 'global_protect'
local service = require 'service'
diff --git a/server/src/log.lua b/server/src/log.lua
index af4212e1..7ebb55cf 100644
--- a/server/src/log.lua
+++ b/server/src/log.lua
@@ -8,7 +8,8 @@ log.size = 0
log.max_size = 100 * 1024 * 1024
local function trim_src(src)
- src = src:sub(log.prefix_len, -5)
+ src = src:sub(log.prefix_len + 1, -5)
+ src = src:gsub('^[/\\]+', '')
src = src:gsub('[\\/]+', '.')
return src
end
@@ -98,7 +99,7 @@ function log.init(root, path)
end
end
log.path = path:string()
- log.prefix_len = #root:string() + 3
+ log.prefix_len = #root:string()
log.size = 0
if not fs.exists(path:parent_path()) then
fs.create_directories(path:parent_path())