mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-01 00:08:27 +01:00
Merge pull request #130 from finn-no/injectable-options
make it possible to require server
This commit is contained in:
commit
746c653cc5
@ -18,12 +18,13 @@
|
||||
"engines": {
|
||||
"node": ">=4.4.3"
|
||||
},
|
||||
"main": "./server.js",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"db-migrate-and-start": "npm run db-migrate && npm run start",
|
||||
"start": "NODE_ENV=production node server.js",
|
||||
"start": "NODE_ENV=production node index.js",
|
||||
"build": "./node_modules/.bin/webpack -p",
|
||||
"dev": "NODE_ENV=development supervisor --ignore ./node_modules/,./public/js server.js",
|
||||
"dev": "NODE_ENV=development supervisor --ignore ./node_modules/,./public/js index.js",
|
||||
"start-pg": "pg_virtualenv npm run start-pg-chain",
|
||||
"start-pg-chain": "export DATABASE_URL=postgres://$PGUSER:$PGPASSWORD@localhost:$PGPORT/postgres ; db-migrate up && npm run dev",
|
||||
"test": "export PORT=4243 ; jest && npm run lint && mocha test test/*.js && npm run coverage",
|
||||
|
17
server.js
17
server.js
@ -1,8 +1,11 @@
|
||||
var logger = require('./lib/logger');
|
||||
var databaseUri = require('./lib/databaseConfig').getDatabaseUrl();
|
||||
var defaultDatabaseUri = require('./lib/databaseConfig').getDatabaseUrl();
|
||||
|
||||
function start(options) {
|
||||
options = options || {};
|
||||
|
||||
var db = require('./lib/db/dbPool')(options.databaseUri || defaultDatabaseUri);
|
||||
// Database dependecies (statefull)
|
||||
var db = require('./lib/db/dbPool')(databaseUri);
|
||||
var eventDb = require('./lib/db/event')(db);
|
||||
var EventStore = require('./lib/eventStore');
|
||||
var eventStore = new EventStore(eventDb);
|
||||
@ -19,6 +22,7 @@ var config = {
|
||||
strategyDb: strategyDb
|
||||
};
|
||||
|
||||
|
||||
var app = require('./app')(config);
|
||||
|
||||
var server = app.listen(app.get('port'), function() {
|
||||
@ -39,12 +43,17 @@ if (app.get('env') === 'development') {
|
||||
}));
|
||||
}
|
||||
|
||||
return {
|
||||
app: app,
|
||||
server: server
|
||||
};
|
||||
}
|
||||
|
||||
process.on('uncaughtException', function(err) {
|
||||
logger.error('Uncaught Exception:', err.message);
|
||||
logger.error(err.stack);
|
||||
});
|
||||
|
||||
module.exports = {
|
||||
app: app,
|
||||
server: server
|
||||
start: start
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user