mirror of
https://github.com/pa11y/pa11y-dashboard.git
synced 2025-09-24 14:21:13 +00:00
Improve the console messaging on starting the app to avoid confusion. (#292)
* Improve the console messaging on starting the app to avoid confusion. * Revise logging to present intended URI alongside actual --------- Co-authored-by: Danyal Aytekin <danyal@alienpaper.com>
This commit is contained in:
3
app.js
3
app.js
@@ -38,7 +38,6 @@ function initApp(config, callback) {
|
||||
|
||||
const app = new EventEmitter();
|
||||
|
||||
app.address = null;
|
||||
app.express = express();
|
||||
app.server = http.createServer(app.express);
|
||||
app.webservice = createClient(webserviceUrl);
|
||||
@@ -179,8 +178,6 @@ function loadErrorHandling(app, config, callback) {
|
||||
});
|
||||
|
||||
app.server.listen(config.port, error => {
|
||||
const address = app.server.address();
|
||||
app.address = `http://${address.address}:${address.port}`;
|
||||
callback(error, app);
|
||||
});
|
||||
}
|
||||
|
28
index.js
28
index.js
@@ -14,24 +14,33 @@
|
||||
// along with Pa11y Dashboard. If not, see <http://www.gnu.org/licenses/>.
|
||||
'use strict';
|
||||
|
||||
const initService = require('pa11y-webservice');
|
||||
const kleur = require('kleur');
|
||||
|
||||
const config = require('./config');
|
||||
const initDashboard = require('./app');
|
||||
|
||||
process.on('SIGINT', () => {
|
||||
console.log('\nGracefully shutting down from SIGINT (Ctrl-C)');
|
||||
process.exit();
|
||||
});
|
||||
|
||||
require('./app')(config, (error, app) => {
|
||||
initDashboard(config, (error, app) => {
|
||||
if (error) {
|
||||
console.error(error.stack);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
console.log('');
|
||||
console.log(kleur.underline().magenta('Pa11y Dashboard started'));
|
||||
console.log(kleur.grey('mode: %s'), process.env.NODE_ENV);
|
||||
console.log(kleur.grey('uri: %s'), app.address);
|
||||
const mode = process.env.NODE_ENV;
|
||||
const dashboardAddress = app.server.address();
|
||||
|
||||
console.log(kleur.underline().magenta('\nPa11y Dashboard started'));
|
||||
console.log(kleur.grey('mode: %s'), mode);
|
||||
console.log(kleur.grey('uri (intended): %s'), `http://localhost:${config.port}/`);
|
||||
console.log(
|
||||
kleur.grey(`uri (actual, ${dashboardAddress.family}): %s`),
|
||||
`http://${dashboardAddress.address}:${dashboardAddress.port}/`
|
||||
);
|
||||
|
||||
app.on('route-error', routeError => {
|
||||
const stack = (routeError.stack ? routeError.stack.split('\n') : [routeError.message]);
|
||||
@@ -43,19 +52,18 @@ require('./app')(config, (error, app) => {
|
||||
|
||||
// Start the webservice if required
|
||||
if (typeof config.webservice === 'object') {
|
||||
require('pa11y-webservice')(config.webservice, (webserviceError, webservice) => {
|
||||
console.log(kleur.underline().cyan('\nPa11y Webservice starting'));
|
||||
initService(config.webservice, (webserviceError, webservice) => {
|
||||
if (webserviceError) {
|
||||
console.error(webserviceError.stack);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
console.log('');
|
||||
console.log(kleur.underline().cyan('Pa11y Webservice started'));
|
||||
console.log(kleur.grey('mode: %s'), process.env.NODE_ENV);
|
||||
console.log(kleur.cyan('\nPa11y Webservice started'));
|
||||
console.log(kleur.grey('mode: %s'), mode);
|
||||
console.log(kleur.grey('uri: %s'), webservice.server.info.uri);
|
||||
console.log(kleur.grey('database: %s'), config.webservice.database);
|
||||
console.log(kleur.grey('cron: %s'), config.webservice.cron);
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
Reference in New Issue
Block a user