@@ -77,7 +77,12 @@ class ParseServer {
77
77
78
78
const allControllers = controllers . getControllers ( options ) ;
79
79
80
- const { loggerController, databaseController, hooksController } = allControllers ;
80
+ const {
81
+ loggerController,
82
+ databaseController,
83
+ hooksController,
84
+ liveQueryController,
85
+ } = allControllers ;
81
86
this . config = Config . put ( Object . assign ( { } , options , allControllers ) ) ;
82
87
83
88
logging . setLogger ( loggerController ) ;
@@ -98,6 +103,7 @@ class ParseServer {
98
103
) {
99
104
startupPromises . push ( options . cacheAdapter . connect ( ) ) ;
100
105
}
106
+ startupPromises . push ( liveQueryController . connect ( ) ) ;
101
107
await Promise . all ( startupPromises ) ;
102
108
if ( serverStartComplete ) {
103
109
serverStartComplete ( ) ;
@@ -263,7 +269,7 @@ class ParseServer {
263
269
* @param {Function } callback called when the server has started
264
270
* @returns {ParseServer } the parse server instance
265
271
*/
266
- start ( options : ParseServerOptions , callback : ?( ) = > void ) {
272
+ async start ( options : ParseServerOptions , callback : ?( ) = > void ) {
267
273
const app = express ( ) ;
268
274
if ( options . middleware ) {
269
275
let middleware ;
@@ -307,7 +313,7 @@ class ParseServer {
307
313
this . server = server ;
308
314
309
315
if ( options . startLiveQueryServer || options . liveQueryServerOptions ) {
310
- this . liveQueryServer = ParseServer . createLiveQueryServer (
316
+ this . liveQueryServer = await ParseServer . createLiveQueryServer (
311
317
server ,
312
318
options . liveQueryServerOptions ,
313
319
options
@@ -338,9 +344,9 @@ class ParseServer {
338
344
* @param {Server } httpServer an optional http server to pass
339
345
* @param {LiveQueryServerOptions } config options for the liveQueryServer
340
346
* @param {ParseServerOptions } options options for the ParseServer
341
- * @returns {ParseLiveQueryServer } the live query server instance
347
+ * @returns {Promise< ParseLiveQueryServer> } the live query server instance
342
348
*/
343
- static createLiveQueryServer (
349
+ static async createLiveQueryServer (
344
350
httpServer ,
345
351
config : LiveQueryServerOptions ,
346
352
options : ParseServerOptions
@@ -350,7 +356,9 @@ class ParseServer {
350
356
httpServer = require ( 'http' ) . createServer ( app ) ;
351
357
httpServer . listen ( config . port ) ;
352
358
}
353
- return new ParseLiveQueryServer ( httpServer , config , options ) ;
359
+ const server = new ParseLiveQueryServer ( httpServer , config , options ) ;
360
+ await server . connect ( ) ;
361
+ return server ;
354
362
}
355
363
356
364
static verifyServerUrl ( callback ) {
0 commit comments