| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- import {
- initInstrumentation,
- setupAdditionalResourceAttributes,
- startOpenTelemetry,
- } from '~/features/opentelemetry/server';
- import loggerFactory from '~/utils/logger';
- import { hasProcessFlag } from '~/utils/process-utils';
- const logger = loggerFactory('growi');
- /** **********************************
- * Main Process
- ********************************** */
- process.on('uncaughtException', (err?: Error) => {
- logger.error({ err }, 'Uncaught Exception');
- });
- process.on('unhandledRejection', (reason, p) => {
- logger.error({ reason, promise: p }, 'Unhandled Rejection');
- });
- async function main() {
- try {
- // Initialize OpenTelemetry
- await initInstrumentation();
- const Crowi = (await import('./crowi')).default;
- const growi = new Crowi();
- const server = await growi.start();
- // Start OpenTelemetry
- await setupAdditionalResourceAttributes();
- startOpenTelemetry();
- if (hasProcessFlag('ci')) {
- logger.info('"--ci" flag is detected. Exit process.');
- server.close(() => {
- process.exit();
- });
- }
- } catch (err) {
- logger.error('An error occurred, unable to start the server');
- logger.error(err);
- process.exit(1);
- }
- }
- main();
|