import Server from './server' ; import { getConfig , getSecrets } from './config-helper' ; async function initialize ( ) { await getSecrets ( ) ; } async function runServer ( ) { await initialize ( ) ; process . on ( 'uncaughtException' , function ( err ) { if ( err . code === 'EADDRINUSE' ) { console . error ( 'ERROR: server already running' ) ; } else { console . error ( 'uncaught exception' , err ) ; process . exit ( 1 ) ; } } ) ; process . on ( 'unhandledRejection' , r => console . error ( 'unhandled promise rejection' , r ) ) ; if ( require . main === module ) { let server = new Server ( ) ; server . run ( { doImport : getConfig ( ) . IMPORT_SENTENCES } ) . catch ( e => console . log ( 'error while starting server' , e ) ) ; } } runServer ( ) ;