-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
39 lines (33 loc) · 972 Bytes
/
Copy pathserver.js
File metadata and controls
39 lines (33 loc) · 972 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
38
39
const BobaServer = require('./src/server/BobaServer');
const { parseBrowserTypeFromArgs } = require('./src/utils/helpers');
const defaultBrowserType = parseBrowserTypeFromArgs();
process.on('SIGINT', handleShutdown);
process.on('SIGTERM', handleShutdown);
const server = new BobaServer({
defaultBrowserType,
port: process.env.PORT || 8084
});
let bobaServerInstance = null;
async function startServer() {
try {
console.log(`Starting Boba server...`);
await server.start();
bobaServerInstance = server;
} catch (error) {
console.error('Failed to start server:', error);
process.exit(1);
}
}
async function handleShutdown() {
console.log('Shutting down server...');
if (bobaServerInstance) {
try {
await bobaServerInstance.stop();
console.log('Server shutdown complete');
} catch (error) {
console.error('Error during shutdown:', error);
}
}
process.exit(0);
}
startServer().catch(console.error);