mirror of
https://github.com/zhigang1992/deployd.git
synced 2026-05-23 21:35:38 +08:00
logging and config changes
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
var express = require('express')
|
||||
, app = express.createServer()
|
||||
, db = require('./db').db
|
||||
, config = require('./config').load()
|
||||
, config = require('./config')
|
||||
, MongoStore = require('connect-mongodb');
|
||||
;
|
||||
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
// dependencies for initial app load
|
||||
require('./log');
|
||||
// use spawn inheritance
|
||||
require('./spawn');
|
||||
// custom logging
|
||||
|
||||
lib = {};
|
||||
|
||||
var config = require('./config').load()
|
||||
var config = require('./config')
|
||||
, fs = require('fs')
|
||||
, app = require('./app')
|
||||
, plugins = fs.readdirSync(__dirname + '/plugins')
|
||||
|
||||
@@ -1,23 +1,11 @@
|
||||
var CONFIG_PATH = './config/'
|
||||
, fs = require('fs')
|
||||
, cache = {};
|
||||
|
||||
exports.load = function(path) {
|
||||
var data = fs.readFileSync(CONFIG_PATH + (path || (path = 'app.json')))
|
||||
, json = cache[path] || (cache[path] = JSON.parse(data))
|
||||
, bootedJSON = bootParams()
|
||||
;
|
||||
|
||||
if(bootedJSON) {
|
||||
for(var key in bootedJSON) {
|
||||
if(bootedJSON.hasOwnProperty(key)) {
|
||||
json[key] = bootedJSON[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return json;
|
||||
};
|
||||
, util = require('util')
|
||||
, cache = {}
|
||||
, data = fs.readFileSync(CONFIG_PATH + 'app.json')
|
||||
, json =JSON.parse(data)
|
||||
, bootedJSON = bootParams()
|
||||
;
|
||||
|
||||
function bootParams() {
|
||||
for(var i = 0; i < process.argv.length; i++) {
|
||||
@@ -27,4 +15,19 @@ function bootParams() {
|
||||
return JSON.parse(val.substr(3, val.length - 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(bootedJSON) {
|
||||
for(var key in bootedJSON) {
|
||||
if(bootedJSON.hasOwnProperty(key)) {
|
||||
json[key] = bootedJSON[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var log = 'Configuration \n'
|
||||
+ util.inspect(json);
|
||||
|
||||
console.log(log);
|
||||
|
||||
module.exports = json;
|
||||
@@ -1,4 +1,4 @@
|
||||
var config = require('./config').load()
|
||||
var config = require('./config')
|
||||
, mongodb = require('mongodb')
|
||||
, ObjectID = require('mongodb').BSONPure.ObjectID
|
||||
, connectionString = config['db-host'] + config['db']
|
||||
|
||||
@@ -385,7 +385,7 @@ Model = module.exports = emitter.spawn({
|
||||
collection: _self.collection,
|
||||
name: _self.name || _self.collection
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
delete json._id;
|
||||
_self.description = _self.description || {};
|
||||
@@ -412,6 +412,8 @@ Model = module.exports = emitter.spawn({
|
||||
_self.configure(_self.description, function(err) {
|
||||
if(err) console.error(err);
|
||||
});
|
||||
|
||||
console.info('Updating', _self.name || _self.collection, json);
|
||||
}
|
||||
})
|
||||
.fetch()
|
||||
@@ -446,6 +448,8 @@ Model = module.exports = emitter.spawn({
|
||||
}
|
||||
;
|
||||
|
||||
console.info('Defining routes:', model.name || model.collection);
|
||||
|
||||
function handler(req, res, next) {
|
||||
var query = req.query
|
||||
, id = req.param('id')
|
||||
|
||||
@@ -7,6 +7,8 @@ var Settings = require('../settings/settings')
|
||||
|
||||
var models = module.exports.models = {};
|
||||
var refresh = module.exports.refresh = function() {
|
||||
|
||||
|
||||
Settings
|
||||
.spawn()
|
||||
.find({plugin: 'models'})
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
var app = require('../../app')
|
||||
, config = require('../../config').load()
|
||||
, config = require('../../config')
|
||||
, Settings = require('./settings')
|
||||
, Setting = require('./setting')
|
||||
, models = require('../models')
|
||||
|
||||
Reference in New Issue
Block a user