@@ -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
@@ -341,9 +347,9 @@ class ParseServer {
341347 * @param {Server } httpServer an optional http server to pass
342348 * @param {LiveQueryServerOptions } config options for the liveQueryServer
343349 * @param {ParseServerOptions } options options for the ParseServer
344- * @returns {ParseLiveQueryServer } the live query server instance
350+ * @returns {Promise< ParseLiveQueryServer> } the live query server instance
345351 */
346- static createLiveQueryServer (
352+ static async createLiveQueryServer (
347353 httpServer ,
348354 config : LiveQueryServerOptions ,
349355 options : ParseServerOptions
@@ -353,7 +359,9 @@ class ParseServer {
353359 httpServer = require ( 'http' ) . createServer ( app ) ;
354360 httpServer . listen ( config . port ) ;
355361 }
356- return new ParseLiveQueryServer ( httpServer , config , options ) ;
362+ const server = new ParseLiveQueryServer ( httpServer , config , options ) ;
363+ await server . connect ( ) ;
364+ return server ;
357365 }
358366
359367 static verifyServerUrl ( callback ) {
0 commit comments