mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-09-07 08:26:57 +08:00
🐛 Fix(custom): fix error handling in server startup
This commit is contained in:
@@ -164,10 +164,11 @@ class Server {
|
|||||||
port = parseInt(port, 10)
|
port = parseInt(port, 10)
|
||||||
}
|
}
|
||||||
this.httpServer.listen(port, this.config.host).on('error', async (err: ErrnoException) => {
|
this.httpServer.listen(port, this.config.host).on('error', async (err: ErrnoException) => {
|
||||||
if (err.errno === 'EADDRINUSE') {
|
if (err.code === 'EADDRINUSE') {
|
||||||
try {
|
try {
|
||||||
// make sure the system has a PicGo Server instance
|
// make sure the system has a PicGo Server instance
|
||||||
await axios.post(ensureHTTPLink(`${this.config.host}:${port}/heartbeat`))
|
await axios.post(ensureHTTPLink(`${this.config.host}:${port}/heartbeat`))
|
||||||
|
logger.info(`[PicList Server] server is already running at ${port}`)
|
||||||
this.shutdown(true)
|
this.shutdown(true)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.warn(`[PicList Server] ${port} is busy, trying with port ${(port as number) + 1}`)
|
logger.warn(`[PicList Server] ${port} is busy, trying with port ${(port as number) + 1}`)
|
||||||
|
|||||||
Reference in New Issue
Block a user