-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathrunner.js
25 lines (21 loc) · 889 Bytes
/
runner.js
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
import dotenv from 'dotenv';
import { runConfigInBackground } from "./src/controllers/runner.js";
import { initUtils } from './src/util.js';
import { RunnerPayload } from './src/executor/runner.js';
dotenv.config();
initUtils();
const payload = JSON.parse(process.env.RUNNER_PAYLOAD);
console.log(`Executing`, payload);
const cleanUpServer = ( /** @type {any} */ code, msg) => {
console.log(`Exiting runner node ${process.pid} with code ${code}`);
if (msg) {
console.log('Additional context: ' + JSON.stringify(msg, Object.getOwnPropertyNames(msg)));
}
};
[`exit`, `SIGINT`, `SIGUSR1`, `SIGUSR2`, `uncaughtException`, `SIGTERM`].forEach((eventType) => {
process.on(eventType, cleanUpServer.bind(null, eventType));
})
runConfigInBackground(new RunnerPayload(payload)).catch(err => {
console.error(err);
});
console.log(`Starting runner node ${process.pid}`);