我的 node.js 应用程序有以下内容app.js
。当我直接运行它时,node app.js
一切正常。当我从 init.d 运行它时,没有load
加载 express-load 中的任何项目。我在所有控制器和配置文件中添加了一个简单的 console.log 行,但没有记录。
难道我做错了什么?
"use strict";
var express = require('express'), // main js framework
http = require('http'), // node http stack
fs = require('fs'), // filesystem
load = require('express-load'), // enables load ("config").then ("models").into("app")
path = require('path'), // enables multi os capable pathes
configure = require(path.join(__dirname, 'lib', 'configure')),
app = module.exports = express(),
server = http.createServer(app);
app.rootDir = __dirname;
// app settings
load('config/development.js') // load main app config
.then('config/production.js') // then load db models
.then('models') // then load db models
.then('controllers') // then load controllers
.then('config/routes.js') // then load routes
.into(app); // load it all into app
configure.loadConfig(app);
// connect to the db
//var db = require('nano')(app.get('db_conn'));
server.listen(app.get('port'), function () {
console.log("Server listening on port %d in %s mode", app.get('port'), app.get('env'));
});