【发布时间】:2016-09-01 20:14:27
【问题描述】:
我整个星期都在努力将我托管在 parse.com 上的应用程序迁移到解析服务器,设法让一切工作完美,唯一的问题是让它在单个硬件上运行多个应用程序,而无需分配服务器应用程序,它会变得昂贵。
我阅读了这个discussion关于它,并在此基础上,遵循以下解决方案:
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);
这一直有效,直到测试环境可以使用多个应用程序在同一硬件上发送推送,只需创建指向不同数据库的服务器解析的多个实例。
谁能告诉我生产中的应用程序是否会出现问题? 这会在将来给我带来麻烦吗?
有人支持这个解决方案吗?
谢谢!
【问题讨论】:
标签: parse-platform push-notification parse-server