forked from browserless/browserless
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
41 lines (39 loc) · 1.25 KB
/
index.ts
File metadata and controls
41 lines (39 loc) · 1.25 KB
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
40
41
import { Browserless, Logger } from '@browserless.io/browserless';
(async () => {
const browserless = new Browserless();
const logger = new Logger('index.js');
browserless.start();
process
.on('unhandledRejection', async (reason, promise) => {
console.error('Unhandled Rejection at:', promise, 'reason:', reason);
})
.once('uncaughtException', async (err, origin) => {
console.error('Unhandled exception at:', origin, 'error:', err);
await browserless.stop();
process.exit(1);
})
.once('SIGTERM', async () => {
logger.info(`SIGTERM received, saving and closing down`);
await browserless.stop();
process.exit(0);
})
.once('SIGINT', async () => {
logger.info(`SIGINT received, saving and closing down`);
await browserless.stop();
process.exit(0);
})
.once('SIGHUP', async () => {
logger.info(`SIGHUP received, saving and closing down`);
await browserless.stop();
process.exit(0);
})
.once('SIGUSR2', async () => {
logger.info(`SIGUSR2 received, saving and closing down`);
await browserless.stop();
process.exit(0);
})
.once('exit', () => {
logger.info(`Process is finished, exiting`);
process.exit(0);
});
})();