Browse Source

Change server port config && sign child process ID

Honor Lee 6 years ago
parent
commit
5fd4105b26
3 changed files with 13 additions and 9 deletions
  1. 3 0
      config.js
  2. 5 4
      server.js
  3. 5 5
      system/lib/core/logger.js

+ 3 - 0
config.js

@@ -1,6 +1,9 @@
 global.Config = {
+    ServerName:'',
+    ServerPort:8080,
     //Session ExpireTime min.
     SessionExpire : 30,
+    RenewSessionOnRead:true,
     //Asset path
     asset_path  : 'asset',
     upload_path : 'asset/upload',

+ 5 - 4
server.js

@@ -11,16 +11,17 @@
   DO NOT CHANGE ANYTHING IN THIS FILE!
  */
 global.ROOTPATH = __dirname;
+global.serverUID = (Math.ceil(Math.random()*61439+4096)).toString(16).toUpperCase();
+
 require('./config.js');
 require('./system/core.js');
 
-let serverPort = 8000;
-
+let serverPort = Config.ServerPort;
 try{
     require('http').createServer(serverHandler).listen(serverPort);
-    LOGGER.info('Child Server start at port [' + serverPort + '] | ' + DateFormat('yyyy/MM/dd hh:mm:ss', new Date()));
+    LOGGER.info('Child Server ['+serverUID+'] start at port [' + serverPort + '] | ' + DateFormat('yyyy/MM/dd hh:mm:ss', new Date()));
 }catch(e){
-    LOGGER.error('Child Server failed start at port [' + serverPort + '] | ' + DateFormat('yyyy/MM/dd hh:mm:ss', new Date()));
+    LOGGER.error('Child Server ['+serverUID+'] failed start at port [' + serverPort + '] | ' + DateFormat('yyyy/MM/dd hh:mm:ss', new Date()));
 }
 
 

+ 5 - 5
system/lib/core/logger.js

@@ -3,19 +3,19 @@ const colors = require('colors');
 
 var Logger = {
     log:function(msg){
-        console.log('[LOG] '+msg);
+        console.log('['+serverUID+'][LOG] '+msg);
         if(Config.write_log_file) this.out('log',msg);
     },
     info:function(msg){
-        console.log(('[INF] '+msg).green);
+        console.log(('['+serverUID+'][INF] '+msg).green);
         if(Config.write_log_file) this.out('info',msg);
     },
     debug:function(msg){
-        if(Config.debug) console.log(('[DEBUG] '+msg).yellow);
-        if(Config.write_log_file) this.out('debug',msg);
+        if(Config.debug) console.log(('['+serverUID+'][DEBUG] '+msg).yellow);
+        // if(Config.write_log_file) this.out('debug',msg);
     },
     error:function(msg){
-        console.log(('[ERR] '+msg).red);
+        console.log(('['+serverUID+'][ERR] '+msg).red);
         if(Config.write_error_file) this.out('error',msg);
     },
     out:function(level,msg){