@@ -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
@@ -341,9 +347,9 @@ class ParseServer {
341
347
* @param {Server } httpServer an optional http server to pass
342
348
* @param {LiveQueryServerOptions } config options for the liveQueryServer
343
349
* @param {ParseServerOptions } options options for the ParseServer
344
- * @returns {ParseLiveQueryServer } the live query server instance
350
+ * @returns {Promise< ParseLiveQueryServer> } the live query server instance
345
351
*/
346
- static createLiveQueryServer (
352
+ static async createLiveQueryServer (
347
353
httpServer ,
348
354
config : LiveQueryServerOptions ,
349
355
options : ParseServerOptions
@@ -353,7 +359,9 @@ class ParseServer {
353
359
httpServer = require ( 'http' ) . createServer ( app ) ;
354
360
httpServer . listen ( config . port ) ;
355
361
}
356
- return new ParseLiveQueryServer ( httpServer , config , options ) ;
362
+ const server = new ParseLiveQueryServer ( httpServer , config , options ) ;
363
+ await server . connect ( ) ;
364
+ return server ;
357
365
}
358
366
359
367
static verifyServerUrl ( callback ) {
0 commit comments