1
1
/* eslint-disable no-console */
2
+ /* eslint-env node */
2
3
3
4
'use strict' ;
4
5
@@ -10,36 +11,36 @@ const FastBootAppServer = require('fastboot-app-server');
10
11
const cluster = require ( 'cluster' ) ;
11
12
12
13
class LoggerWithoutTimestamp {
13
- constructor ( ) {
14
- this . prefix = cluster . isMaster ? 'master' : 'worker' ;
15
- }
16
- writeLine ( ) {
17
- this . _write ( 'info' , Array . prototype . slice . apply ( arguments ) ) ;
18
- }
19
-
20
- writeError ( ) {
21
- this . _write ( 'error' , Array . prototype . slice . apply ( arguments ) ) ;
22
- }
23
-
24
- _write ( level , args ) {
25
- args [ 0 ] = `[${ level } ][${ this . prefix } ] ${ args [ 0 ] } ` ;
26
- console . log . apply ( console , args ) ;
27
- }
14
+ constructor ( ) {
15
+ this . prefix = cluster . isMaster ? 'master' : 'worker' ;
16
+ }
17
+ writeLine ( ) {
18
+ this . _write ( 'info' , Array . prototype . slice . apply ( arguments ) ) ;
19
+ }
20
+
21
+ writeError ( ) {
22
+ this . _write ( 'error' , Array . prototype . slice . apply ( arguments ) ) ;
23
+ }
24
+
25
+ _write ( level , args ) {
26
+ args [ 0 ] = `[${ level } ][${ this . prefix } ] ${ args [ 0 ] } ` ;
27
+ console . log . apply ( console , args ) ;
28
+ }
28
29
}
29
30
30
31
function writeAppInitializedWhenReady ( logger ) {
31
- let timeout ;
32
-
33
- timeout = setInterval ( function ( ) {
34
- logger . writeLine ( 'waiting backend' ) ;
35
- if ( fs . existsSync ( '/tmp/backend-initialized' ) ) {
36
- logger . writeLine ( 'backend is up. let heroku know the app is ready' ) ;
37
- fs . writeFileSync ( '/tmp/app-initialized' , 'hello' ) ;
38
- clearInterval ( timeout ) ;
39
- } else {
40
- logger . writeLine ( 'backend is still not up' ) ;
41
- }
42
- } , 1000 ) ;
32
+ let timeout ;
33
+
34
+ timeout = setInterval ( function ( ) {
35
+ logger . writeLine ( 'waiting backend' ) ;
36
+ if ( fs . existsSync ( '/tmp/backend-initialized' ) ) {
37
+ logger . writeLine ( 'backend is up. let heroku know the app is ready' ) ;
38
+ fs . writeFileSync ( '/tmp/app-initialized' , 'hello' ) ;
39
+ clearInterval ( timeout ) ;
40
+ } else {
41
+ logger . writeLine ( 'backend is still not up' ) ;
42
+ }
43
+ } , 1000 ) ;
43
44
}
44
45
45
46
var logger = new LoggerWithoutTimestamp ( ) ;
@@ -49,14 +50,14 @@ logger.writeLine(`${os.cpus().length} cores available`);
49
50
let workerCount = process . env . WEB_CONCURRENCY || 1 ;
50
51
51
52
let server = new FastBootAppServer ( {
52
- distPath : 'dist' ,
53
- port : 9000 ,
54
- ui : logger ,
55
- workerCount : workerCount ,
53
+ distPath : 'dist' ,
54
+ port : 9000 ,
55
+ ui : logger ,
56
+ workerCount : workerCount ,
56
57
} ) ;
57
58
58
59
if ( ! cluster . isWorker ) {
59
- writeAppInitializedWhenReady ( logger ) ;
60
+ writeAppInitializedWhenReady ( logger ) ;
60
61
}
61
62
62
63
server . start ( ) ;
0 commit comments