Permalink
Browse files

node re eval bug

  • Loading branch information...
1 parent e43012e commit 8e3ccbcd869dbb5ef72cf2901e159a9edbd1d6dc @jindw committed May 3, 2014
Showing with 11 additions and 5 deletions.
  1. +1 −0 index.js
  2. +1 −1 package.json
  3. +9 −3 server.js
  4. +0 −1 start.js
View
1 index.js
@@ -57,5 +57,6 @@ exports.parseCode = parseCode;
exports.parseMarkdown = parseMarkdown;
exports.seekMarkdown = seekMarkdown;
exports.start = function(root){
+ console.log('## start!')
require('./server').start(root);
};
View
2 package.json
@@ -4,7 +4,7 @@
"author": "bae",
"description": "The first bae nodejs app!",
"scripts": {
- "start": "node server.js"
+ "start": "node start.js"
},
"main": "./index.js",
"dependencies": {
View
12 server.js
@@ -2,9 +2,15 @@ var LiteEngine = require('lite').LiteEngine;
var path = require('path');
var fs = require('fs');
var http = require('http');
+var engine;
function start(root){
+ if(engine != null){//node 一个重复执行的奇怪问题
+ return ;
+ }
+ //console.log('@@@'+new Error().stack)
root = path.resolve(root || './');
- var engine = new LiteEngine(root);
+ engine = new LiteEngine(root);
+ var port = process.env.APP_PORT || 18080;
require('lite/test/file-server').createServer(function (req, response,root) {
var url = req.url;
var param = {};
@@ -31,7 +37,7 @@ function start(root){
return true;
}
- },root).listen(process.env.APP_PORT || 18080);
- console.log('lite test server is started: http://127.0.0.1:'+(process.env.APP_PORT || 18080));
+ },root).listen(port);
+ console.log('lite test server is started: http://localhost:'+(port));
}
exports.start = start;
View
1 start.js
@@ -1 +0,0 @@
-require('./server').start();

0 comments on commit 8e3ccbc

Please sign in to comment.