2026-02-24 01:43:22 -08:00
|
|
|
#!/usr/bin/env -S node --no-warnings=DEP0040
|
2025-10-10 01:47:18 +02:00
|
|
|
|
2025-08-26 20:49:25 +00:00
|
|
|
/**
|
|
|
|
|
* @license
|
|
|
|
|
* Copyright 2025 Google LLC
|
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import * as url from 'node:url';
|
|
|
|
|
import * as path from 'node:path';
|
|
|
|
|
|
2025-09-03 10:24:48 -04:00
|
|
|
import { logger } from '../utils/logger.js';
|
|
|
|
|
import { main } from './app.js';
|
2025-08-26 20:49:25 +00:00
|
|
|
|
2025-10-10 01:47:18 +02:00
|
|
|
// Check if the module is the main script being run
|
2025-08-26 20:49:25 +00:00
|
|
|
const isMainModule =
|
2025-10-10 01:47:18 +02:00
|
|
|
path.basename(process.argv[1]) ===
|
|
|
|
|
path.basename(url.fileURLToPath(import.meta.url));
|
2025-08-26 20:49:25 +00:00
|
|
|
|
|
|
|
|
if (
|
|
|
|
|
import.meta.url.startsWith('file:') &&
|
|
|
|
|
isMainModule &&
|
|
|
|
|
process.env['NODE_ENV'] !== 'test'
|
|
|
|
|
) {
|
2025-10-10 01:47:18 +02:00
|
|
|
process.on('uncaughtException', (error) => {
|
|
|
|
|
logger.error('Unhandled exception:', error);
|
|
|
|
|
process.exit(1);
|
|
|
|
|
});
|
|
|
|
|
|
2025-08-26 20:49:25 +00:00
|
|
|
main().catch((error) => {
|
|
|
|
|
logger.error('[CoreAgent] Unhandled error in main:', error);
|
|
|
|
|
process.exit(1);
|
|
|
|
|
});
|
|
|
|
|
}
|