mirror of
https://gitlab.silvrtree.co.uk/martind2000/nci.git
synced 2025-02-10 18:09:15 +00:00
add server config
This commit is contained in:
parent
7b2fe328a7
commit
bf97e2c7c5
46
app.js
46
app.js
@ -4,7 +4,10 @@ var http = require('http'),
|
||||
nodeStatic = require('node-static'),
|
||||
jade = require('jade'),
|
||||
path = require('path'),
|
||||
fs = require('fs');
|
||||
fs = require('fs'),
|
||||
Steppy = require('twostep').Steppy,
|
||||
_ = require('underscore'),
|
||||
reader = require('./lib/reader');
|
||||
|
||||
var staticServer = new nodeStatic.Server('./static');
|
||||
var server = http.createServer(function(req, res, next) {
|
||||
@ -29,17 +32,38 @@ var app = {
|
||||
dataio: dataio
|
||||
};
|
||||
|
||||
app.config = {};
|
||||
app.config.paths = {};
|
||||
|
||||
// path to root dir (with projects, builds etc)
|
||||
app.config.paths.data = path.join(process.cwd(), 'data');
|
||||
app.config.paths.projects = path.join(app.config.paths.data, 'projects');
|
||||
app.config.paths.builds = path.join(app.config.paths.data, 'builds');
|
||||
fs.exists(app.config.paths.builds, function(exists) {
|
||||
if (!exists) fs.mkdir(app.config.paths.builds);
|
||||
});
|
||||
Steppy(
|
||||
function() {
|
||||
app.config = {};
|
||||
app.config.paths = {};
|
||||
|
||||
require('./resources')(app);
|
||||
// path to root dir (with projects, builds etc)
|
||||
app.config.paths.data = path.join(process.cwd(), 'data');
|
||||
app.config.paths.projects = path.join(app.config.paths.data, 'projects');
|
||||
app.config.paths.builds = path.join(app.config.paths.data, 'builds');
|
||||
var stepCallback = this.slot();
|
||||
fs.exists(app.config.paths.builds, function(isExists) {
|
||||
stepCallback(null, isExists);
|
||||
});
|
||||
|
||||
reader.load(app.config.paths.data, 'config', this.slot());
|
||||
},
|
||||
function(err, isBuildsDirExists, config) {
|
||||
if (!isBuildsDirExists) {
|
||||
fs.mkdir(app.config.paths.builds, this.slot());
|
||||
}
|
||||
|
||||
_(app.config).defaults(config);
|
||||
|
||||
console.log('Server config:', JSON.stringify(app.config.nodes, null, 4));
|
||||
|
||||
require('./resources')(app);
|
||||
|
||||
},
|
||||
function(err) {
|
||||
if (err) throw err;
|
||||
}
|
||||
);
|
||||
|
||||
app.server.listen(3000);
|
||||
|
6
data/config.json
Normal file
6
data/config.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"nodes": [{
|
||||
"type": "local",
|
||||
"maxExecutorsCount": 1
|
||||
}]
|
||||
}
|
@ -30,7 +30,7 @@ gulp.task('develop', function() {
|
||||
return nodemon({
|
||||
ignore: ['static/**/*.js', 'app/**/*.js', 'node_modules/**'],
|
||||
script: 'app.js',
|
||||
ext: 'js'
|
||||
ext: 'js,json'
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -27,7 +27,7 @@ module.exports = function(app) {
|
||||
});
|
||||
|
||||
var distributor = new Distributor({
|
||||
nodes: [{type: 'local', maxExecutorsCount: 1}],
|
||||
nodes: app.config.nodes,
|
||||
saveBuild: function(build, callback) {
|
||||
Steppy(
|
||||
function() {
|
||||
|
Loading…
Reference in New Issue
Block a user