14
14
// along with Pa11y Dashboard. If not, see <http://www.gnu.org/licenses/>.
15
15
'use strict' ;
16
16
17
+ const initService = require ( 'pa11y-webservice' ) ;
17
18
const kleur = require ( 'kleur' ) ;
19
+
18
20
const config = require ( './config' ) ;
21
+ const initDashboard = require ( './app' ) ;
19
22
20
23
process . on ( 'SIGINT' , ( ) => {
21
24
console . log ( '\nGracefully shutting down from SIGINT (Ctrl-C)' ) ;
22
25
process . exit ( ) ;
23
26
} ) ;
24
27
25
- require ( './app' ) ( config , ( error , app ) => {
28
+ initDashboard ( config , ( error , app ) => {
26
29
if ( error ) {
27
30
console . error ( error . stack ) ;
28
31
process . exit ( 1 ) ;
29
32
}
30
33
31
- console . log ( '' ) ;
32
- console . log ( kleur . underline ( ) . magenta ( 'Pa11y Dashboard started' ) ) ;
33
- console . log ( kleur . grey ( 'mode: %s' ) , process . env . NODE_ENV ) ;
34
- console . log ( kleur . grey ( 'uri: %s' ) , app . address ) ;
34
+ const mode = process . env . NODE_ENV ;
35
+ const dashboardAddress = app . server . address ( ) ;
36
+
37
+ console . log ( kleur . underline ( ) . magenta ( '\nPa11y Dashboard started' ) ) ;
38
+ console . log ( kleur . grey ( 'mode: %s' ) , mode ) ;
39
+ console . log ( kleur . grey ( 'uri (intended): %s' ) , `http://localhost:${ config . port } /` ) ;
40
+ console . log (
41
+ kleur . grey ( `uri (actual, ${ dashboardAddress . family } ): %s` ) ,
42
+ `http://${ dashboardAddress . address } :${ dashboardAddress . port } /`
43
+ ) ;
35
44
36
45
app . on ( 'route-error' , routeError => {
37
46
const stack = ( routeError . stack ? routeError . stack . split ( '\n' ) : [ routeError . message ] ) ;
@@ -43,19 +52,18 @@ require('./app')(config, (error, app) => {
43
52
44
53
// Start the webservice if required
45
54
if ( typeof config . webservice === 'object' ) {
46
- require ( 'pa11y-webservice' ) ( config . webservice , ( webserviceError , webservice ) => {
55
+ console . log ( kleur . underline ( ) . cyan ( '\nPa11y Webservice starting' ) ) ;
56
+ initService ( config . webservice , ( webserviceError , webservice ) => {
47
57
if ( webserviceError ) {
48
58
console . error ( webserviceError . stack ) ;
49
59
process . exit ( 1 ) ;
50
60
}
51
61
52
- console . log ( '' ) ;
53
- console . log ( kleur . underline ( ) . cyan ( 'Pa11y Webservice started' ) ) ;
54
- console . log ( kleur . grey ( 'mode: %s' ) , process . env . NODE_ENV ) ;
62
+ console . log ( kleur . cyan ( '\nPa11y Webservice started' ) ) ;
63
+ console . log ( kleur . grey ( 'mode: %s' ) , mode ) ;
55
64
console . log ( kleur . grey ( 'uri: %s' ) , webservice . server . info . uri ) ;
56
65
console . log ( kleur . grey ( 'database: %s' ) , config . webservice . database ) ;
57
66
console . log ( kleur . grey ( 'cron: %s' ) , config . webservice . cron ) ;
58
67
} ) ;
59
68
}
60
-
61
69
} ) ;
0 commit comments