File tree Expand file tree Collapse file tree 2 files changed +27
-2
lines changed Expand file tree Collapse file tree 2 files changed +27
-2
lines changed Original file line number Diff line number Diff line change 1+ /* eslint-disable no-console */
2+
13'use strict' ;
24
5+ const fs = require ( 'fs' ) ;
36const FastBootAppServer = require ( 'fastboot-app-server' ) ;
47
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+
526let server = new FastBootAppServer ( {
627 distPath : 'dist' ,
728 port : 9000 ,
829} ) ;
930
31+ if ( ! cluster . isWorker ) {
32+ writeAppInitializedWhenReady ( ) ;
33+ }
34+
1035server . 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