I worked all week to migrate my apps hosted on parse.com to parse server, managed to make everything work perfectly, the only problem is to get it to run multiple apps on a single hardware, without my having to allocate a server app for that it has, it would become expensive.
I read this discussion about it, and on this basis, follow the following solution:
var app1 = new ParseServer({
databaseURI: databaseUri || 'mongodb://localhost:27017/dev',
cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
appId: process.env.APP_ID || 'myAppId1',
masterKey: process.env.MASTER_KEY || 'myMasterKey1', //Add your master key here. Keep it secret!
serverURL: process.env.SERVER_URL || 'http://localhost:1337/parse', // Don't forget to change to https if needed
push: pushConfig,
liveQuery: {
classNames: ["Posts", "Comments"] // List of classes to support for query subscriptions
}
});
var app2 = new ParseServer({
databaseURI: databaseUri || 'mongodb://localhost:27017/app2',
cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
appId: process.env.APP_ID || 'myAppId2',
masterKey: process.env.MASTER_KEY || 'myMasterKey2', //Add your master key here. Keep it secret!
serverURL: process.env.SERVER_URL || 'http://localhost:1337/parse', // Don't forget to change to https if needed
push: pushConfig,
liveQuery: {
classNames: ["Posts", "Comments"] // List of classes to support for query subscriptions
}
});
// Client-keys like the javascript key or the .NET key are not necessary with parse-server
// If you wish you require them, you can set them as options in the initialization above:
// javascriptKey, restAPIKey, dotNetKey, clientKey
var app = express();
// Serve static assets from the /public folder
app.use('/public', express.static(path.join(__dirname, '/public')));
// Serve the Parse API on the /parse URL prefix
var mountPath = process.env.PARSE_MOUNT || '/parse';
app.use(mountPath, app1);
app.use(mountPath, app2);
This works until the time test environment can use multiple apps for sending push on the same hardware, just creating multiple instances of the server parse pointing to different database.
Can anyone tell me if something could go wrong with the apps in production? This would cause me a problem in the future?
Someone supports this solution?
Thank you!
Parse Server as of v2.2.9 doesn't offer multi-app support.
It requires individual instances (and mount paths) for each app. You would otherwise run into complications regarding cloud code as the core is not designed for multi-app support although it carries some legacy from Parse.com like the appId
property which would be a step towards it.
However since it is now an open source project it may offer multi-app support in the future.
Parse server v2.2.18 still does only supports one single app per instance, according to the wiki:
Parse Server only supports single app instances. There is ongoing work to make Parse Server multi-app aware. However, if you intend to run many different apps with different datastores, you currently would need to instantiate separate instances.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With