-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.ts
More file actions
37 lines (29 loc) · 705 Bytes
/
Copy pathserver.ts
File metadata and controls
37 lines (29 loc) · 705 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { serve } from 'remix/node-serve'
import { router } from './app/router.ts'
const port = process.env.PORT ? Number.parseInt(process.env.PORT, 10) : 44100
const server = serve(
async (request) => {
try {
return await router.fetch(request)
} catch (error) {
console.error(error)
return new Response('Internal Server Error', { status: 500 })
}
},
{
port,
},
)
await server.ready
console.log(`Server listening on http://localhost:${server.port}`)
let shuttingDown = false
function shutdown() {
if (shuttingDown) {
return
}
shuttingDown = true
server.close()
process.exit(0)
}
process.on('SIGINT', shutdown)
process.on('SIGTERM', shutdown)