Skip to content

Commit

Permalink
feat: integrated vlmcsd program
Browse files Browse the repository at this point in the history
  • Loading branch information
ikxin committed May 7, 2024
1 parent f65c123 commit dc47212
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 1 deletion.
1 change: 0 additions & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"arrowParens": "avoid",
"printWidth": 120,
"semi": false,
"singleQuote": true
}
Binary file added service/binaries/vlmcs-darwin-arm64
Binary file not shown.
Binary file added service/binaries/vlmcs-darwin-x64
Binary file not shown.
Binary file added service/binaries/vlmcs-darwin-x86
Binary file not shown.
Binary file added service/binaries/vlmcsd-darwin-arm64
Binary file not shown.
Binary file added service/binaries/vlmcsd-darwin-x64
Binary file not shown.
Binary file added service/binaries/vlmcsd-darwin-x86
Binary file not shown.
35 changes: 35 additions & 0 deletions service/index.ts
Original file line number Diff line number Diff line change
@@ -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()

Expand All @@ -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')
}

0 comments on commit dc47212

Please sign in to comment.