我的应用程序使用node.js(10.28)和express(3.4.7)server.js就是这样
var express = require('express'),
config = require('./services/resource/config.js'),
routeprocess = require('./services/routeprocess/routeprocess.js'),
socketevent = require('./socketevent'),
cluster = require('cluster'),
RedisStore = require('socket.io/lib/stores/redis')
redis = require('socket.io/node_modules/redis')
numCPUs = require('os').cpus().length;
logger = require('./services/logger/logger.js');
var channels=['XXXXXX','YYYYYY','ZZZZZZZZZZ'];
app = express();
app.use(express.compress());
app.use(express.favicon());
app.use(app.router);
app.use(function(req, res){
res.sendfile(__dirname + '/web/'+ req.url );
});
app.use(function(err,req,res,next) {
console.log(err);
});
app.get('/', function(req, res){
res.sendfile(__dirname + '/web/'+ 'index.html' );
});
// couple of REST Calls
app.all('/rest/summary/:code?', function (req, res) {
routeprocess.onStoreGraphSummary(req, res, req.params.storeCode);
});
app.all('/rest/offerdetails/:offerNos?', function (req, res) {
routeprocess.onOfferDetails(req, res, req.params.offerNos);
});
app.use(express.static(__dirname + '/web',{ maxAge: 2592000000 }));
// Below this we have the forking / redisstore , socket etc
问题是,一旦服务器启动并运行几分钟,我们就会开始收到很多错误:ENOENT
类似这样的事情
Error: ENOENT, stat '/home/auto/xxxx/appp/4Jun/8180/web//dashsummary'
[2014-06-04 04:31:52.130] [INFO] console - { [Error: ENOENT, stat '/home/auto/xxxx/appp/4Jun/8180/web//dashsummary']
errno: 34,
code: 'ENOENT',
path: '/home/auto/xxxx/appp/4Jun/8180/web//dashsummary',
status: 404 }
/ dashsummary是我的routeprovider中的AngularJS应用程序中提到的有效链接
$routeProvider
.when('/dashsummary', {
controller: 'DashController',
templateUrl: 'view/modules/dashsummary.html'
})
这些错误:ENOENT发生了很多次,我觉得NodeJS服务器完全停留在此
感谢任何帮助
由于
答案 0 :(得分:1)
如果该行应该提供该URL,请尝试删除尾随" /"
res.sendfile(__dirname + '/web/'+ req.url );
到
res.sendfile(__dirname + '/web'+ req.url );