mirror of
				https://github.com/node-red/node-red.git
				synced 2025-03-01 10:36:34 +00:00 
			
		
		
		
	Handle port-in-use error on start-up
This commit is contained in:
		
							
								
								
									
										21
									
								
								red.js
									
									
									
									
									
								
							
							
						
						
									
										21
									
								
								red.js
									
									
									
									
									
								
							| @@ -163,6 +163,16 @@ function getListenPath() { | |||||||
|  |  | ||||||
| RED.start().then(function() { | RED.start().then(function() { | ||||||
|     if (settings.httpAdminRoot !== false || settings.httpNodeRoot !== false || settings.httpStatic) { |     if (settings.httpAdminRoot !== false || settings.httpNodeRoot !== false || settings.httpStatic) { | ||||||
|  |         server.on('error', function(err) { | ||||||
|  |             if (err.errno === "EADDRINUSE") { | ||||||
|  |                 util.log('[red] Unable to listen on '+getListenPath()); | ||||||
|  |                 util.log('[red] Error: port in use'); | ||||||
|  |             } else { | ||||||
|  |                 util.log('[red] Uncaught Exception:'); | ||||||
|  |                 util.log(err.stack); | ||||||
|  |             } | ||||||
|  |             process.exit(1); | ||||||
|  |         }); | ||||||
|         server.listen(settings.uiPort,settings.uiHost,function() { |         server.listen(settings.uiPort,settings.uiHost,function() { | ||||||
|             if (settings.httpAdminRoot === false) { |             if (settings.httpAdminRoot === false) { | ||||||
|                 util.log('[red] Admin UI disabled'); |                 util.log('[red] Admin UI disabled'); | ||||||
| @@ -176,14 +186,9 @@ RED.start().then(function() { | |||||||
|  |  | ||||||
|  |  | ||||||
| process.on('uncaughtException',function(err) { | process.on('uncaughtException',function(err) { | ||||||
|         if (err.errno === "EADDRINUSE") { |     util.log('[red] Uncaught Exception:'); | ||||||
|             util.log('[red] Unable to listen on '+getListenPath()); |     util.log(err.stack); | ||||||
|             util.log('[red] Error: port in use'); |     process.exit(1); | ||||||
|         } else { |  | ||||||
|             util.log('[red] Uncaught Exception:'); |  | ||||||
|             util.log(err.stack); |  | ||||||
|         } |  | ||||||
|         process.exit(1); |  | ||||||
| }); | }); | ||||||
|  |  | ||||||
| process.on('SIGINT', function () { | process.on('SIGINT', function () { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user