// site-service.js // Copyright (C) 2022 DTP Technologies, LLC // License: Apache-2.0 'use strict'; const path = require('path'); const SitePlatform = require(path.join(__dirname, 'site-platform')); const { SiteCommon } = require(path.join(__dirname, 'site-common')); class SiteWorker extends SiteCommon { constructor (dtp, component) { super(dtp, component); } async start ( ) { try { process.on('unhandledRejection', (error, p) => { this.log.error('Unhandled rejection', { error: error, promise: p, stack: error.stack }); }); process.on('warning', (error) => { this.log.alert('warning', { error }); }); process.once('SIGINT', async ( ) => { this.log.info('SIGINT received'); this.log.info('requesting shutdown...'); await this.stop(); const exitCode = await SitePlatform.shutdown(); process.nextTick(( ) => { process.exit(exitCode); }); }); /* * Site Platform startup */ await SitePlatform.startPlatform(this.dtp); } catch (error) { this.log.error('failed to start worker', { component: this.dtp.config.component, error, }); process.exit(-1); } } async stop ( ) { } } module.exports.SiteWorker = SiteWorker;