File tree Expand file tree Collapse file tree 2 files changed +25
-2
lines changed Expand file tree Collapse file tree 2 files changed +25
-2
lines changed Original file line number Diff line number Diff line change 11'use strict' ;
22
3+ const fs = require ( 'fs' ) ;
34const FastBootAppServer = require ( 'fastboot-app-server' ) ;
45
6+ // because fastboot-app-server uses cluster, but it might change in future
7+ const cluster = require ( 'cluster' ) ;
8+
9+ function writeAppInitializedWhenReady ( ) {
10+ let timeout ;
11+
12+ timeout = setInterval ( function ( ) {
13+ console . log ( 'waiting backend' ) ;
14+ if ( fs . existsSync ( '/tmp/backend-initialized' ) ) {
15+ console . log ( 'backend is up. let heroku know the app is ready' ) ;
16+ fs . writeFileSync ( '/tmp/app-initialized' , 'hello' ) ;
17+ clearInterval ( timeout ) ;
18+ } else {
19+ console . log ( 'backend is still not up' ) ;
20+ }
21+ } , 1000 ) ;
22+ }
23+
524let server = new FastBootAppServer ( {
625 distPath : 'dist' ,
726 port : 9000 ,
827} ) ;
928
29+ if ( ! cluster . isWorker ) {
30+ writeAppInitializedWhenReady ( ) ;
31+ }
32+
1033server . start ( ) ;
Original file line number Diff line number Diff line change @@ -102,8 +102,8 @@ fn main() {
102102 // Creating this file tells heroku to tell nginx that the application is ready
103103 // to receive traffic.
104104 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 ( ) ;
107107 }
108108
109109 // Block the main thread until the server has shutdown
You can’t perform that action at this time.
0 commit comments