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!