Skip to content

Commit 926134f

Browse files
committed
fix(stage-tamagotchi): omit server startup error
1 parent 37b4721 commit 926134f

File tree

1 file changed

+26
-21
lines changed
  • apps/stage-tamagotchi/src/main/services/airi/channel-server

1 file changed

+26
-21
lines changed

apps/stage-tamagotchi/src/main/services/airi/channel-server/index.ts

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,32 +14,37 @@ export async function setupChannelServer() {
1414
const { serve } = await import('h3')
1515
const { plugin: ws } = await import('crossws/server')
1616

17-
const serverInstance = serve(serverRuntime.app, {
17+
try {
18+
const serverInstance = serve(serverRuntime.app, {
1819
// TODO: fix types
1920
// @ts-expect-error - the .crossws property wasn't extended in types
20-
plugins: [ws({ resolve: async req => (await serverRuntime.app.fetch(req)).crossws })],
21-
port: env.PORT ? Number(env.PORT) : 6121,
22-
hostname: env.SERVER_RUNTIME_HOSTNAME || 'localhost',
23-
reusePort: true,
24-
gracefulShutdown: {
25-
forceTimeout: 500,
26-
gracefulTimeout: 500,
27-
},
28-
})
21+
plugins: [ws({ resolve: async req => (await serverRuntime.app.fetch(req)).crossws })],
22+
port: env.PORT ? Number(env.PORT) : 6121,
23+
hostname: env.SERVER_RUNTIME_HOSTNAME || 'localhost',
24+
reusePort: true,
25+
gracefulShutdown: {
26+
forceTimeout: 500,
27+
gracefulTimeout: 500,
28+
},
29+
})
2930

30-
log.log('@proj-airi/server-runtime started on ws://localhost:6121')
31+
log.log('@proj-airi/server-runtime started on ws://localhost:6121')
3132

32-
onAppBeforeQuit(async () => {
33-
if (serverInstance && typeof serverInstance.close === 'function') {
34-
try {
35-
await serverInstance.close()
36-
log.log('WebSocket server closed')
33+
onAppBeforeQuit(async () => {
34+
if (serverInstance && typeof serverInstance.close === 'function') {
35+
try {
36+
await serverInstance.close()
37+
log.log('WebSocket server closed')
38+
}
39+
catch (error) {
40+
log.withError(error).error('Error closing WebSocket server')
41+
}
3742
}
38-
catch (error) {
39-
log.withError(error).error('Error closing WebSocket server')
40-
}
41-
}
42-
})
43+
})
44+
}
45+
catch (error) {
46+
log.withError(error).error('failed to start WebSocket server')
47+
}
4348
}
4449
catch (error) {
4550
log.withError(error).error('failed to start WebSocket server')

0 commit comments

Comments
 (0)