@@ -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
- } ) ;
1023
-
1024
- server . listen ( port , host , ( ) => {
1013
+ const listeningListener = ( ) => {
1025
1014
const addressInfo = server . address ( ) as net . AddressInfo ;
1026
1015
const address = addressInfo . address === '0.0.0.0' || addressInfo . address === '127.0.0.1' ? 'localhost' : addressInfo . address ;
1027
1016
const formattedPort = addressInfo . port === 80 ? '' : String ( addressInfo . port ) ;
1028
1017
logService . info ( `Web UI available at http://${ address } :${ formattedPort } ` ) ;
1029
- } ) ;
1018
+ } ;
1019
+
1020
+ if ( parsedArgs . socket ) {
1021
+ server . listen ( parsedArgs . socket , listeningListener ) ;
1022
+ } else {
1023
+ let port = 3000 ;
1024
+ if ( parsedArgs . port ) {
1025
+ port = Number ( parsedArgs . port ) ;
1026
+ } else if ( typeof options . port === 'number' ) {
1027
+ port = options . port ;
1028
+ }
1029
+
1030
+ const host = parsedArgs . host || '0.0.0.0' ;
1031
+ server . on ( 'error' , ( ) => {
1032
+ server . close ( ) ;
1033
+ process . exit ( 1 ) ;
1034
+ } ) ;
1035
+ server . listen ( port , host , listeningListener ) ;
1036
+ }
1030
1037
1031
1038
} ) ;
1032
1039
}
0 commit comments