@@ -302,11 +302,13 @@ async function handleFetchCallback(req: http.IncomingMessage, res: http.ServerRe
302
302
interface ServerParsedArgs extends NativeParsedArgs {
303
303
port ?: string
304
304
host ?: string
305
+ socket ?: string
305
306
}
306
307
const SERVER_OPTIONS : OptionDescriptions < ServerParsedArgs > = {
307
308
...OPTIONS ,
308
309
port : { type : 'string' } ,
309
- host : { type : 'string' }
310
+ host : { type : 'string' } ,
311
+ socket : { type : 'string' }
310
312
} ;
311
313
312
314
export interface IStartServerResult {
@@ -1008,25 +1010,30 @@ export async function main(options: IServerOptions): Promise<void> {
1008
1010
} ) ;
1009
1011
} ) ;
1010
1012
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
+ }
1023
1024
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
+ }
1030
1037
1031
1038
} ) ;
1032
1039
}
0 commit comments