parse-community / parse-server

Parse Server for Node.js / Express
https://parseplatform.org
Apache License 2.0
20.87k stars 4.78k forks source link

Multiple instances not working after upgrade to 3.0.0 #5774

Closed adamokasha closed 5 years ago

adamokasha commented 5 years ago

Issue Description

Previously running parse-server@2.8.2 and parse@1.11.1 where we created multiple instances of parse server like so:

const app1Config = require('./cloud/app1Config/appConfig.json');
const app2Config = require('./cloud/app2Config/appConfig.json');
const app3Config = require('./cloud/app3Config/appConfig.json');
const app4Config = require('./cloud/app4Config/appConfig.json');

const app1EnvVars =  {
    appId: app1Config.appId,
    ...
}

...

const app1 = new ParseServer(app1EnvVars);
const app2 = new ParseServer(app2EnvVars);
const app3 = new ParseServer(app3EnvVars);
const app4 = new ParseServer(app4EnvVars);

let app = express();

// Serve the Parse API on the /parse URL prefix
let mountPath = '/parse';
app.use(mountPath, app1);
app.use(mountPath, app2);
app.use(mountPath, app3);
app.use(mountPath, app4);

...

let httpServer = require('https').createServer(options, app);
httpServer.listen(port, function () {
    logger.info({
        message: `Parse Server running on port: ${port}`
    });
});

After upgrading to parse-server@3.0.0 and parse@2.0.0 all cloud code functions point to the last initialized ParseServer.

Steps to reproduce

Code above.

Expected Results

Previous behaviour. Multiple instances bound to correct dbs.

Actual Outcome

All cloud code functions point to the last initialized ParseServer.

Environment Setup

Logs/Trace

davimacedo commented 5 years ago

Is the code below correct?

// Serve the Parse API on the /parse URL prefix
let mountPath = '/parse';
app.use(mountPath, app1);
app.use(mountPath, app2);
app.use(mountPath, app3);
app.use(mountPath, app4);

Are you mounting all instances in the same endpoint?

adamokasha commented 5 years ago

Is the code below correct?

Are you mounting all instances in the same endpoint?

Yes. I neglected to mention, only app1 calls cloud code function. The rest are not.

davimacedo commented 5 years ago

Can you please explain further what you need to achieve by mounting different Parse Server instances in the same endpoint? I can't imagine what is the use case and it can be related to your problem. I'd expect something like this instead:

app.use('/parse1', app1);
app.use('/parse2', app2);
app.use('/parse3', app3);
app.use('/parse4', app4);
adamokasha commented 5 years ago

Can you please explain further what you need to achieve by mounting different Parse Server instances in the same endpoint? I can't imagine what is the use case and it can be related to your problem. I'd expect something like this instead:

I'm not on the mobile team but I believe they need the sdk for mobile and the dashboard but without cloud code. The example I posted above was I believe from somewhere on stackoverflow or it was posted in a github issue.

Either way I don't think its an issue for us anymore so I will close. Thanks.