import * as Logger from "../common/Logger" ; import { BlobServerFactory } from "./BlobServerFactory" ; import SqlBlobServer from "./SqlBlobServer" ; import BlobServer from "./BlobServer" ; function shutdown ( server ) { const beforeCloseMessage = `Azurite Blob service is closing...` ; const afterCloseMessage = `Azurite Blob service successfully closed` ; console . log ( beforeCloseMessage ) ; server . close ( ) . then ( ( ) => { console . log ( afterCloseMessage ) ; } ) ; } /**
 * Entry for Azurite blob service.
 */ async function main ( ) { const blobServerFactory = new BlobServerFactory ( ) ; const server = await blobServerFactory . createServer ( ) ; const config = server . config ; Logger . configLogger ( config . enableDebugLog , config . debugLogFilePath ) ; console . log ( `Azurite Blob service is starting on ${ config . host }:${ config . port }` ) ; await server . start ( ) ; console . log ( `Azurite Blob service successfully listens on ${ server . getHttpServerAddress ( ) }` ) ; process . once ( "message" , ( msg ) => { if ( msg === "shutdown" ) { shutdown ( server ) ; } } ) . once ( "SIGINT" , ( ) => shutdown ( server ) ) . once ( "SIGTERM" , ( ) => shutdown ( server ) ) ; } main ( ) . catch ( ( err ) => { console . error ( `Exit due to unhandled error: ${ err . message }` ) ; process . exit ( 1 ) ; } ) ;