이민호

change port

...@@ -4,16 +4,16 @@ ...@@ -4,16 +4,16 @@
4 * Module dependencies. 4 * Module dependencies.
5 */ 5 */
6 6
7 -var app = require('../app'); 7 +var app = require("../app");
8 -var debug = require('debug')('screensaver:server'); 8 +var debug = require("debug")("screensaver:server");
9 -var http = require('http'); 9 +var http = require("http");
10 10
11 /** 11 /**
12 * Get port from environment and store in Express. 12 * Get port from environment and store in Express.
13 */ 13 */
14 14
15 -var port = normalizePort(process.env.PORT || '3000'); 15 +var port = normalizePort(process.env.PORT || "8080");
16 -app.set('port', port); 16 +app.set("port", port);
17 17
18 /** 18 /**
19 * Create HTTP server. 19 * Create HTTP server.
...@@ -26,8 +26,8 @@ var server = http.createServer(app); ...@@ -26,8 +26,8 @@ var server = http.createServer(app);
26 */ 26 */
27 27
28 server.listen(port); 28 server.listen(port);
29 -server.on('error', onError); 29 +server.on("error", onError);
30 -server.on('listening', onListening); 30 +server.on("listening", onListening);
31 31
32 /** 32 /**
33 * Normalize a port into a number, string, or false. 33 * Normalize a port into a number, string, or false.
...@@ -54,22 +54,20 @@ function normalizePort(val) { ...@@ -54,22 +54,20 @@ function normalizePort(val) {
54 */ 54 */
55 55
56 function onError(error) { 56 function onError(error) {
57 - if (error.syscall !== 'listen') { 57 + if (error.syscall !== "listen") {
58 throw error; 58 throw error;
59 } 59 }
60 60
61 - var bind = typeof port === 'string' 61 + var bind = typeof port === "string" ? "Pipe " + port : "Port " + port;
62 - ? 'Pipe ' + port
63 - : 'Port ' + port;
64 62
65 // handle specific listen errors with friendly messages 63 // handle specific listen errors with friendly messages
66 switch (error.code) { 64 switch (error.code) {
67 - case 'EACCES': 65 + case "EACCES":
68 - console.error(bind + ' requires elevated privileges'); 66 + console.error(bind + " requires elevated privileges");
69 process.exit(1); 67 process.exit(1);
70 break; 68 break;
71 - case 'EADDRINUSE': 69 + case "EADDRINUSE":
72 - console.error(bind + ' is already in use'); 70 + console.error(bind + " is already in use");
73 process.exit(1); 71 process.exit(1);
74 break; 72 break;
75 default: 73 default:
...@@ -83,8 +81,6 @@ function onError(error) { ...@@ -83,8 +81,6 @@ function onError(error) {
83 81
84 function onListening() { 82 function onListening() {
85 var addr = server.address(); 83 var addr = server.address();
86 - var bind = typeof addr === 'string' 84 + var bind = typeof addr === "string" ? "pipe " + addr : "port " + addr.port;
87 - ? 'pipe ' + addr 85 + debug("Listening on " + bind);
88 - : 'port ' + addr.port;
89 - debug('Listening on ' + bind);
90 } 86 }
......