单个解析服务器中有多个应用 [英] Multiple apps in a single parse server

查看:93
本文介绍了单个解析服务器中有多个应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我整整一周的工作是将托管在parse.com上的应用程序迁移到解析服务器,设法使一切正常运行,唯一的问题是让它可以在单个硬件上运行多个应用程序,而不必分配服务器的应用程序,它将变得昂贵.

我阅读了有关此内容的讨论,并在此基础上遵循以下解决方案:

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);

这一直有效,直到时间测试环境可以使用多个应用程序在同一硬件上发送推送信息,而只是创建指向不同数据库的服务器解析实例.

有人可以告诉我生产中的应用程序是否会出问题吗? 将来会给我带来麻烦吗?

有人支持此解决方案吗?

谢谢!

解决方案

从v2.2.9开始解析服务器不提供多应用程序支持.

每个应用程序需要单独的实例(和安装路径).否则,您会遇到有关云代码的麻烦,因为它的核心不是为多应用程序支持而设计的,尽管它具有来自Parse.com的一些遗留物,例如appId属性,这将是向它迈出的一步.

但是,由于它现在是一个开源项目,因此将来可能会提供多应用程序支持.

更新

根据 Wiki :

Parse Server仅支持单个应用程序实例.正在进行中 使Parse Server具有多应用程序感知能力.但是,如果您打算跑步 许多具有不同数据存储区的不同应用程序,您当前会 需要实例化单独的实例.

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.

Update

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.

这篇关于单个解析服务器中有多个应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆