@@ -302,11 +302,13 @@ async function handleFetchCallback(req: http.IncomingMessage, res: http.ServerRe
302302interface ServerParsedArgs extends NativeParsedArgs {
303303 port ?: string
304304 host ?: string
305+ socket ?: string
305306}
306307const SERVER_OPTIONS : OptionDescriptions < ServerParsedArgs > = {
307308 ...OPTIONS ,
308309 port : { type : 'string' } ,
309- host : { type : 'string' }
310+ host : { type : 'string' } ,
311+ socket : { type : 'string' }
310312} ;
311313
312314export interface IStartServerResult {
@@ -1008,25 +1010,30 @@ export async function main(options: IServerOptions): Promise<void> {
10081010 } ) ;
10091011 } ) ;
10101012
1011- let port = 3000 ;
1012- if ( parsedArgs . port ) {
1013- port = Number ( parsedArgs . port ) ;
1014- } else if ( typeof options . port === 'number' ) {
1015- port = options . port ;
1016- }
1017-
1018- const host = parsedArgs . host || '0.0.0.0' ;
1019- server . on ( 'error' , ( ) => {
1020- server . close ( ) ;
1021- process . exit ( 1 ) ;
1022- } ) ;
1013+ if ( parsedArgs . socket ) {
1014+ server . listen ( parsedArgs . socket , ( ) => {
1015+ logService . info ( `Server listening on ${ parsedArgs . socket } ` ) ;
1016+ } ) ;
1017+ } else {
1018+ let port = 3000 ;
1019+ if ( parsedArgs . port ) {
1020+ port = Number ( parsedArgs . port ) ;
1021+ } else if ( typeof options . port === 'number' ) {
1022+ port = options . port ;
1023+ }
10231024
1024- server . listen ( port , host , ( ) => {
1025- const addressInfo = server . address ( ) as net . AddressInfo ;
1026- const address = addressInfo . address === '0.0.0.0' || addressInfo . address === '127.0.0.1' ? 'localhost' : addressInfo . address ;
1027- const formattedPort = addressInfo . port === 80 ? '' : String ( addressInfo . port ) ;
1028- logService . info ( `Web UI available at http://${ address } :${ formattedPort } ` ) ;
1029- } ) ;
1025+ const host = parsedArgs . host || '0.0.0.0' ;
1026+ server . on ( 'error' , ( ) => {
1027+ server . close ( ) ;
1028+ process . exit ( 1 ) ;
1029+ } ) ;
1030+ server . listen ( port , host , ( ) => {
1031+ const addressInfo = server . address ( ) as net . AddressInfo ;
1032+ const address = addressInfo . address === '0.0.0.0' || addressInfo . address === '127.0.0.1' ? 'localhost' : addressInfo . address ;
1033+ const formattedPort = addressInfo . port === 80 ? '' : String ( addressInfo . port ) ;
1034+ logService . info ( `Web UI available at http://${ address } :${ formattedPort } ` ) ;
1035+ } ) ;
1036+ }
10301037
10311038 } ) ;
10321039}
0 commit comments