File tree Expand file tree Collapse file tree 3 files changed +18
-14
lines changed Expand file tree Collapse file tree 3 files changed +18
-14
lines changed Original file line number Diff line number Diff line change @@ -97,17 +97,6 @@ export class MongoStorageAdapter {
9797
9898 // MaxTimeMS is not a global MongoDB client option, it is applied per operation.
9999 this . _maxTimeMS = mongoOptions . maxTimeMS ;
100- process . on ( 'SIGTERM' , this . handleShutdown ( this ) ) ;
101- process . on ( 'SIGINT' , this . handleShutdown ( this ) ) ;
102- }
103-
104- handleShutdown ( storageAdapter ) {
105- return ( ) => {
106- if ( ! storageAdapter . database ) {
107- return ;
108- }
109- storageAdapter . database . close ( false ) ;
110- }
111100 }
112101
113102 connect ( ) {
@@ -139,6 +128,13 @@ export class MongoStorageAdapter {
139128 return this . connectionPromise ;
140129 }
141130
131+ handleShutdown ( ) {
132+ if ( ! this . database ) {
133+ return ;
134+ }
135+ this . database . close ( false ) ;
136+ }
137+
142138 _adaptiveCollection ( name : string ) {
143139 return this . connect ( )
144140 . then ( ( ) => this . database . collection ( this . _collectionPrefix + name ) )
Original file line number Diff line number Diff line change @@ -313,6 +313,13 @@ class ParseServer {
313313 return ParseServer . app ( this . config ) ;
314314 }
315315
316+ handleShutdown ( ) {
317+ const { adapter } = this . config . databaseController ;
318+ if ( adapter && typeof adapter . handleShutdown === 'function' ) {
319+ adapter . handleShutdown ( ) ;
320+ }
321+ }
322+
316323 static app ( { maxUploadSize = '20mb' , appId} ) {
317324 // This app serves the Parse API directly.
318325 // It's the equivalent of https://api.parse.com/1 in the hosted Parse API.
Original file line number Diff line number Diff line change 11/* eslint-disable no-console */
22import express from 'express' ;
3- import { ParseServer } from '../index' ;
3+ import ParseServer from '../index' ;
44import definitions from './definitions/parse-server' ;
55import cluster from 'cluster' ;
66import os from 'os' ;
@@ -43,9 +43,9 @@ function startServer(options, callback) {
4343 app . use ( middleware ) ;
4444 }
4545
46- const api = new ParseServer ( options ) ;
46+ const parseServer = new ParseServer ( options ) ;
4747 const sockets = { } ;
48- app . use ( options . mountPath , api ) ;
48+ app . use ( options . mountPath , parseServer . app ) ;
4949
5050 const server = app . listen ( options . port , options . host , callback ) ;
5151 server . on ( 'connection' , initializeConnections ) ;
@@ -85,6 +85,7 @@ function startServer(options, callback) {
8585 console . log ( 'Termination signal received. Shutting down.' ) ;
8686 destroyAliveConnections ( ) ;
8787 server . close ( ) ;
88+ parseServer . handleShutdown ( ) ;
8889 } ;
8990 process . on ( 'SIGTERM' , handleShutdown ) ;
9091 process . on ( 'SIGINT' , handleShutdown ) ;
You can’t perform that action at this time.
0 commit comments