@@ -77,7 +77,12 @@ class ParseServer {
7777
7878 const allControllers = controllers . getControllers ( options ) ;
7979
80- const { loggerController, databaseController, hooksController } = allControllers ;
80+ const {
81+ loggerController,
82+ databaseController,
83+ hooksController,
84+ liveQueryController,
85+ } = allControllers ;
8186 this . config = Config . put ( Object . assign ( { } , options , allControllers ) ) ;
8287
8388 logging . setLogger ( loggerController ) ;
@@ -98,6 +103,7 @@ class ParseServer {
98103 ) {
99104 startupPromises . push ( options . cacheAdapter . connect ( ) ) ;
100105 }
106+ startupPromises . push ( liveQueryController . connect ( ) ) ;
101107 await Promise . all ( startupPromises ) ;
102108 if ( serverStartComplete ) {
103109 serverStartComplete ( ) ;
@@ -263,7 +269,7 @@ class ParseServer {
263269 * @param {Function } callback called when the server has started
264270 * @returns {ParseServer } the parse server instance
265271 */
266- start ( options : ParseServerOptions , callback : ?( ) = > void ) {
272+ async start ( options : ParseServerOptions , callback : ?( ) = > void ) {
267273 const app = express ( ) ;
268274 if ( options . middleware ) {
269275 let middleware ;
@@ -307,7 +313,7 @@ class ParseServer {
307313 this . server = server ;
308314
309315 if ( options . startLiveQueryServer || options . liveQueryServerOptions ) {
310- this . liveQueryServer = ParseServer . createLiveQueryServer (
316+ this . liveQueryServer = await ParseServer . createLiveQueryServer (
311317 server ,
312318 options . liveQueryServerOptions ,
313319 options
@@ -338,9 +344,9 @@ class ParseServer {
338344 * @param {Server } httpServer an optional http server to pass
339345 * @param {LiveQueryServerOptions } config options for the liveQueryServer
340346 * @param {ParseServerOptions } options options for the ParseServer
341- * @returns {ParseLiveQueryServer } the live query server instance
347+ * @returns {Promise< ParseLiveQueryServer> } the live query server instance
342348 */
343- static createLiveQueryServer (
349+ static async createLiveQueryServer (
344350 httpServer ,
345351 config : LiveQueryServerOptions ,
346352 options : ParseServerOptions
@@ -350,7 +356,9 @@ class ParseServer {
350356 httpServer = require ( 'http' ) . createServer ( app ) ;
351357 httpServer . listen ( config . port ) ;
352358 }
353- return new ParseLiveQueryServer ( httpServer , config , options ) ;
359+ const server = new ParseLiveQueryServer ( httpServer , config , options ) ;
360+ await server . connect ( ) ;
361+ return server ;
354362 }
355363
356364 static verifyServerUrl ( callback ) {
0 commit comments