diff --git a/.prettierrc.json b/.prettierrc.json index 004eaa81..f3c3c08f 100644 --- a/.prettierrc.json +++ b/.prettierrc.json @@ -1,6 +1,5 @@ { "arrowParens": "avoid", - "printWidth": 120, "semi": false, "singleQuote": true } diff --git a/service/binaries/vlmcs-darwin-arm64 b/service/binaries/vlmcs-darwin-arm64 new file mode 100755 index 00000000..604724d4 Binary files /dev/null and b/service/binaries/vlmcs-darwin-arm64 differ diff --git a/service/binaries/vlmcs-darwin-x64 b/service/binaries/vlmcs-darwin-x64 new file mode 100755 index 00000000..414b4fc0 Binary files /dev/null and b/service/binaries/vlmcs-darwin-x64 differ diff --git a/service/binaries/vlmcs-darwin-x86 b/service/binaries/vlmcs-darwin-x86 new file mode 100755 index 00000000..a145f924 Binary files /dev/null and b/service/binaries/vlmcs-darwin-x86 differ diff --git a/service/binaries/vlmcsd-darwin-arm64 b/service/binaries/vlmcsd-darwin-arm64 new file mode 100755 index 00000000..699c38b6 Binary files /dev/null and b/service/binaries/vlmcsd-darwin-arm64 differ diff --git a/service/binaries/vlmcsd-darwin-x64 b/service/binaries/vlmcsd-darwin-x64 new file mode 100755 index 00000000..64674305 Binary files /dev/null and b/service/binaries/vlmcsd-darwin-x64 differ diff --git a/service/binaries/vlmcsd-darwin-x86 b/service/binaries/vlmcsd-darwin-x86 new file mode 100755 index 00000000..c2ce1a7c Binary files /dev/null and b/service/binaries/vlmcsd-darwin-x86 differ diff --git a/service/index.ts b/service/index.ts index 05f1f1f4..a2f055e8 100644 --- a/service/index.ts +++ b/service/index.ts @@ -1,5 +1,7 @@ import { Elysia } from 'elysia' import { staticPlugin } from '@elysiajs/static' +import { arch, platform } from 'os' +import { $ } from 'bun' const app = new Elysia() @@ -13,3 +15,36 @@ app.use( app.get('/*', () => Bun.file('dist/index.html')) app.listen(3000) + +try { + const { stdout, exitCode } = + platform() === 'win32' + ? await $`netstat -ano | findstr 1688`.nothrow() + : await $`lsof -i :1688 | grep LISTEN`.nothrow() + + if (exitCode === 0) { + const lines = stdout.toString().split('\n') + for (const line of lines) { + const match = line.match(/\b(\d+)\b/) + if (match) { + const pid = match[0] + platform() === 'win32' + ? await $`taskkill /F /PID ${pid}`.nothrow() + : await $`kill -9 ${pid}`.nothrow() + break + } + } + } +} catch (err) { + console.error(err) +} + +console.log(`Elysia is running at on port ${app.server?.url} ...`) + +const vlmcsd = Bun.spawnSync([ + `./service/binaries/vlmcsd-${platform()}-${arch()}`, +]) + +if (vlmcsd.success) { + console.log('Vlmcsd has started') +}