Question

I've got the following app.js for my node.js application. When I run it directly with node app.js everything works. When I run it from init.d, none of the load items from express-load are loaded. I've added a simple console.log line to all my controllers and config files and none are logged.

Am I doing something wrong?

"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'));
});
Était-ce utile?

La solution

That's probably a path problem. Try using paths like ./config/development.js and not config/development.js.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top