|
@@ -7,9 +7,6 @@ var debug = require('debug')('crowi:crowi')
|
|
|
, sep = path.sep
|
|
, sep = path.sep
|
|
|
, Promise = require('bluebird')
|
|
, Promise = require('bluebird')
|
|
|
|
|
|
|
|
- , http = require('http')
|
|
|
|
|
- , express = require('express')
|
|
|
|
|
-
|
|
|
|
|
, mongoose = require('mongoose')
|
|
, mongoose = require('mongoose')
|
|
|
|
|
|
|
|
, models = require('../models')
|
|
, models = require('../models')
|
|
@@ -21,12 +18,13 @@ function Crowi (rootdir, env)
|
|
|
|
|
|
|
|
this.version = pkg.version;
|
|
this.version = pkg.version;
|
|
|
|
|
|
|
|
- this.rootDir = rootdir;
|
|
|
|
|
- this.pluginDir = path.join(this.rootDir, 'node_modules') + sep;
|
|
|
|
|
- this.publicDir = path.join(this.rootDir, 'public') + sep;
|
|
|
|
|
- this.libDir = path.join(this.rootDir, 'lib') + sep;
|
|
|
|
|
- this.viewsDir = path.join(this.libDir, 'views') + sep;
|
|
|
|
|
- this.mailDir = path.join(this.viewsDir, 'mail') + sep;
|
|
|
|
|
|
|
+ this.rootDir = rootdir;
|
|
|
|
|
+ this.pluginDir = path.join(this.rootDir, 'node_modules') + sep;
|
|
|
|
|
+ this.publicDir = path.join(this.rootDir, 'public') + sep;
|
|
|
|
|
+ this.libDir = path.join(this.rootDir, 'lib') + sep;
|
|
|
|
|
+ this.resourceDir = path.join(this.rootDir, 'resource') + sep;
|
|
|
|
|
+ this.viewsDir = path.join(this.libDir, 'views') + sep;
|
|
|
|
|
+ this.mailDir = path.join(this.viewsDir, 'mail') + sep;
|
|
|
|
|
|
|
|
this.config = {};
|
|
this.config = {};
|
|
|
this.mailer = {};
|
|
this.mailer = {};
|
|
@@ -71,8 +69,6 @@ Crowi.prototype.init = function() {
|
|
|
});
|
|
});
|
|
|
}).then(function() {
|
|
}).then(function() {
|
|
|
return self.setupMailer();
|
|
return self.setupMailer();
|
|
|
- }).then(function() {
|
|
|
|
|
- return self.buildServer();
|
|
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -182,25 +178,30 @@ Crowi.prototype.setupMailer = function() {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
-Crowi.prototype.start = function(app) {
|
|
|
|
|
|
|
+Crowi.prototype.start = function() {
|
|
|
var self = this
|
|
var self = this
|
|
|
|
|
+ , http = require('http')
|
|
|
, server
|
|
, server
|
|
|
, io;
|
|
, io;
|
|
|
|
|
|
|
|
- server = http.createServer(app).listen(self.port, function() {
|
|
|
|
|
- console.log('[' + self.node_env + '] Express server listening on port ' + self.port);
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ return self.buildServer()
|
|
|
|
|
+ .then(function(app) {
|
|
|
|
|
+ server = http.createServer(app).listen(self.port, function() {
|
|
|
|
|
+ console.log('[' + self.node_env + '] Express server listening on port ' + self.port);
|
|
|
|
|
+ });
|
|
|
|
|
|
|
|
- io = require('socket.io')(server);
|
|
|
|
|
- io.sockets.on('connection', function (socket) {
|
|
|
|
|
- });
|
|
|
|
|
- this.io = io;
|
|
|
|
|
|
|
+ io = require('socket.io')(server);
|
|
|
|
|
+ io.sockets.on('connection', function (socket) {
|
|
|
|
|
+ });
|
|
|
|
|
+ self.io = io;
|
|
|
|
|
+
|
|
|
|
|
+ return app;
|
|
|
|
|
+ });
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
Crowi.prototype.buildServer = function() {
|
|
Crowi.prototype.buildServer = function() {
|
|
|
- var app = express()
|
|
|
|
|
- , env = this.node_env
|
|
|
|
|
- , sessionConfig = this.setupSessionConfig();
|
|
|
|
|
|
|
+ var express = require('express')
|
|
|
|
|
+ , app = express()
|
|
|
;
|
|
;
|
|
|
|
|
|
|
|
require('./express-init')(this, app);
|
|
require('./express-init')(this, app);
|