Allow the webservice to run automatically

This commit is contained in:
Rowan Manning
2013-11-21 09:12:54 +00:00
parent ec9f82aa6f
commit 8f636173a0
5 changed files with 33 additions and 4 deletions

7
app.js
View File

@@ -13,11 +13,16 @@ module.exports = initApp;
function initApp (config, callback) {
config = defaultConfig(config);
var webserviceUrl = config.webservice;
if (typeof webserviceUrl == 'object') {
webserviceUrl = 'http://' + webserviceUrl.host + ':' + webserviceUrl.port + '/';
}
var app = new EventEmitter();
app.address = null;
app.express = express();
app.server = http.createServer(app.express);
app.webservice = createClient(config.webservice);
app.webservice = createClient(webserviceUrl);
// Compression
app.express.use(express.compress());

View File

@@ -2,5 +2,12 @@
"webservice": "http://localhost:3000/",
"port": 4000,
"noindex": true,
"readonly": false
"readonly": false,
"webservice": {
"database": "mongodb://localhost/pa11y-webservice-dev",
"host": "0.0.0.0",
"port": 3000,
"cron": "0 30 0 * * *"
}
}

View File

@@ -1,6 +1,12 @@
{
"webservice": "http://localhost:3000/",
"port": 4000,
"noindex": true,
"readonly": false
"readonly": false,
"webservice": {
"database": "mongodb://localhost/pa11y-webservice",
"host": "0.0.0.0",
"port": 3000,
"cron": "0 30 0 * * *"
}
}

View File

@@ -18,4 +18,14 @@ require('./app')(config, function (err, app) {
console.error(chalk.grey(stack.join('\n')));
});
// Start the webservice if required
if (typeof config.webservice === 'object') {
require('pa11y-webservice')(config.webservice, function (err, webservice) {
console.log('');
console.log(chalk.underline.cyan('pa11y-webservice started'));
console.log(chalk.grey('mode: %s'), process.env.NODE_ENV);
console.log(chalk.grey('uri: %s'), webservice.server.info.uri);
});
}
});

View File

@@ -25,6 +25,7 @@
"express": "~3.4",
"express-hbs": "~0.2",
"moment": "~2.2",
"pa11y-webservice": "~1.1",
"pa11y-webservice-client-node": "~1.0",
"underscore": "~1.5"
},