@@ -21,8 +21,6 @@ var argv = require('minimist')(process.argv.slice(2), {
2121
2222var ifaces = os . networkInterfaces ( ) ;
2323
24- process . title = 'http-server' ;
25-
2624if ( argv . h || argv . help ) {
2725 console . log ( [
2826 'usage: http-server [path] [options]' ,
@@ -64,6 +62,8 @@ if (argv.h || argv.help) {
6462 ' To disable caching, use -c-1.' ,
6563 ' -t Connection timeout in seconds [120], e.g. -t60 for 1 minute.' ,
6664 ' To disable timeout, use -t0.' ,
65+ ' -T --title Custom title suffix for the terminal window [none]' ,
66+ ' The terminal title will be "http-server PORT [TITLE]"' ,
6767 ' -U --utc Use UTC time format in log messages.' ,
6868 ' --log-ip Enable logging of the client\'s IP address' ,
6969 '' ,
@@ -94,6 +94,7 @@ if (argv.h || argv.help) {
9494var port = argv . p || argv . port || parseInt ( process . env . PORT , 10 ) ,
9595 host = argv . a || '::' ,
9696 tls = argv . S || argv . tls ,
97+ title = argv . T || argv . title ,
9798 sslPassphrase = process . env . NODE_HTTP_SERVER_SSL_PASSPHRASE ,
9899 proxy = argv . P || argv . proxy ,
99100 proxyOptions = argv [ 'proxy-options' ] ,
@@ -311,6 +312,9 @@ function listen(port) {
311312
312313 var server = httpServer . createServer ( options ) ;
313314 server . listen ( port , host , function ( ) {
315+ // Set process title with port and optional custom suffix
316+ process . title = 'http-server ' + port + ( title ? ' ' + title : '' ) ;
317+
314318 var protocol = tls ? 'https://' : 'http://' ,
315319 path = baseDir ? '/' + baseDir . replace ( / ^ \/ / , '' ) : '' ;
316320
0 commit comments