File tree Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -159,10 +159,20 @@ else {
159
159
} ;
160
160
}
161
161
162
- // Create and start server
163
- var server = new LinkedDataFragmentsServer ( config ) ;
164
- server . listen ( port ) ;
165
- console . log ( 'Worker %d running on http://localhost:%d/.' , process . pid , port ) ;
162
+ // Create server, and start it when all data sources are ready
163
+ var server = new LinkedDataFragmentsServer ( config ) ,
164
+ pending = _ . size ( datasources ) ;
165
+ _ . each ( datasources , function ( settings ) {
166
+ var ready = _ . once ( startWhenReady ) ;
167
+ settings . datasource . once ( 'initialized' , ready ) ;
168
+ settings . datasource . once ( 'error' , ready ) ;
169
+ } ) ;
170
+ function startWhenReady ( ) {
171
+ if ( ! -- pending ) {
172
+ server . listen ( port ) ;
173
+ console . log ( 'Worker %d running on http://localhost:%d/.' , process . pid , port ) ;
174
+ }
175
+ }
166
176
167
177
// Terminate gracefully if possible
168
178
process . once ( 'SIGINT' , function ( ) {
You can’t perform that action at this time.
0 commit comments