File tree 2 files changed +27
-2
lines changed
2 files changed +27
-2
lines changed Original file line number Diff line number Diff line change
1
+ /* eslint-disable no-console */
2
+
1
3
'use strict' ;
2
4
5
+ const fs = require ( 'fs' ) ;
3
6
const FastBootAppServer = require ( 'fastboot-app-server' ) ;
4
7
8
+ // because fastboot-app-server uses cluster, but it might change in future
9
+ const cluster = require ( 'cluster' ) ;
10
+
11
+ function writeAppInitializedWhenReady ( ) {
12
+ let timeout ;
13
+
14
+ timeout = setInterval ( function ( ) {
15
+ console . log ( 'waiting backend' ) ;
16
+ if ( fs . existsSync ( '/tmp/backend-initialized' ) ) {
17
+ console . log ( 'backend is up. let heroku know the app is ready' ) ;
18
+ fs . writeFileSync ( '/tmp/app-initialized' , 'hello' ) ;
19
+ clearInterval ( timeout ) ;
20
+ } else {
21
+ console . log ( 'backend is still not up' ) ;
22
+ }
23
+ } , 1000 ) ;
24
+ }
25
+
5
26
let server = new FastBootAppServer ( {
6
27
distPath : 'dist' ,
7
28
port : 9000 ,
8
29
} ) ;
9
30
31
+ if ( ! cluster . isWorker ) {
32
+ writeAppInitializedWhenReady ( ) ;
33
+ }
34
+
10
35
server . start ( ) ;
Original file line number Diff line number Diff line change @@ -102,8 +102,8 @@ fn main() {
102
102
// Creating this file tells heroku to tell nginx that the application is ready
103
103
// to receive traffic.
104
104
if heroku {
105
- println ! ( "Writing to /tmp/app -initialized" ) ;
106
- File :: create ( "/tmp/app -initialized" ) . unwrap ( ) ;
105
+ println ! ( "Writing to /tmp/backend -initialized" ) ;
106
+ File :: create ( "/tmp/backend -initialized" ) . unwrap ( ) ;
107
107
}
108
108
109
109
// Block the main thread until the server has shutdown
You can’t perform that action at this time.
0 commit comments