mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-10 21:06:15 -08:00
refactor(tooling): [MOD-DEV-01] own dev server lifecycle and report port failures
This commit is contained in:
1 parent
401d4cdd65
commit
772d79a671
24 files changed
+1249
-132
No files matched your search
+23
-4
@@ -1,7 +1,26 @@
|
||||
import process from 'node:process'
|
||||
import { runDevelop } from './library/development.ts'
|
||||
|
||||
runDevelop().catch((error) => {
|
||||
console.error('❌ Development server failed:', error)
|
||||
process.exitCode = 1
|
||||
})
|
||||
const abort = new AbortController()
|
||||
const stop = () => abort.abort()
|
||||
process.once('SIGINT', stop)
|
||||
process.once('SIGTERM', stop)
|
||||
|
||||
try {
|
||||
const configured = process.env.ARTPLAYER_DEV_PORT
|
||||
const port = configured === undefined ? 8082 : Number(configured)
|
||||
if (configured?.trim() === '' || !Number.isInteger(port) || port < 0 || port > 65535)
|
||||
throw new Error('ARTPLAYER_DEV_PORT must be an integer from 0 through 65535')
|
||||
const session = await runDevelop({ port, signal: abort.signal })
|
||||
await session?.done
|
||||
}
|
||||
catch (error) {
|
||||
if (!abort.signal.aborted) {
|
||||
console.error('❌ Development server failed:', error)
|
||||
process.exitCode = 1
|
||||
}
|
||||
}
|
||||
finally {
|
||||
process.off('SIGINT', stop)
|
||||
process.off('SIGTERM', stop)
|
||||
}
|
||||
Reference in new issue
Block a user