2022-09-07 17:07:16 +03:00
|
|
|
import { set } from '@balena/es-version';
|
|
|
|
// Set the desired es version for downstream modules that support it, before we import any
|
2024-03-25 16:56:27 +00:00
|
|
|
set('es2022');
|
2022-09-07 17:07:16 +03:00
|
|
|
|
2024-03-25 15:05:13 +00:00
|
|
|
import { setDefaultAutoSelectFamilyAttemptTimeout } from 'net';
|
|
|
|
// Increase the timeout for the happy eyeballs algorithm to 5000ms to avoid issues on slower networks
|
|
|
|
setDefaultAutoSelectFamilyAttemptTimeout(5000);
|
|
|
|
|
2024-04-23 19:21:52 -04:00
|
|
|
// Setup MDNS resolution
|
|
|
|
import './mdns';
|
2019-06-21 12:21:52 +01:00
|
|
|
|
|
|
|
import Supervisor from './supervisor';
|
2024-03-05 15:15:30 -03:00
|
|
|
import process from 'process';
|
2023-01-30 11:47:59 -03:00
|
|
|
import log from './lib/supervisor-console';
|
|
|
|
|
|
|
|
// Register signal handlers before starting the supervisor service
|
|
|
|
process.on('SIGTERM', () => {
|
|
|
|
log.info('Received SIGTERM. Exiting.');
|
|
|
|
|
|
|
|
// This is standard exit code to indicate a graceful shutdown
|
|
|
|
// it equals 128 + 15 (the signal code)
|
|
|
|
process.exit(143);
|
|
|
|
});
|
2019-06-21 12:21:52 +01:00
|
|
|
|
|
|
|
const supervisor = new Supervisor();
|
2023-04-06 16:38:18 -04:00
|
|
|
supervisor.init().catch((e) => {
|
|
|
|
log.error('Uncaught exception:', e);
|
|
|
|
|
|
|
|
// Terminate the process to avoid leaving the supervisor in a bad state
|
|
|
|
process.exit(1);
|
|
|
|
});
|