在一个Node.js环境中运行多个Parse服务器实例

有没有办法在一个Node.js(一台机器)环境中运行多个Parse服务器实例? 如果是,那将是什么configuration。

我专门针对Jelastic,但我认为一般的解决scheme无论如何都适用。

我正在使用这种方式,它的工作完美

// First app instance here var api1 = new ParseServer({ databaseURI: 'mongodb://localhost:27017/dev1', cloud: '/home/myApp/cloud/main1.js', appId: 'myAppId1', masterKey: 'myMasterKey1', fileKey: 'optionalFileKey1', serverURL: 'http://localhost:1337/parse' }); // Second app instance here var api2 = new ParseServer({ databaseURI: 'mongodb://localhost:27017/dev2', // Connection string foryour MongoDB database cloud: '/home/myApp/cloud/main2.js', // Absolute path to your Cloud Code appId: 'myAppId2', masterKey: 'myMasterKey2', // Keep this key secret! fileKey: 'optionalFileKey', serverURL: 'http://localhost:1337/parse' // Don't forget to change to https if needed }); // Serve the Parse API on the /parse URL prefix var mountPath = process.env.PARSE_MOUNT || '/parse'; // Mount Apps here app.use(mountPath, api1); app.use(mountPath, api2); 

希望这可以帮助!! 让我知道

在这里输入图像说明

您可以使用群集模块来运行同一个服务器应用程序的多个实例。 请注意,Node.js中或程序中没有路由逻辑,工作者之间没有共享状态。 因此,devise你的程序是非常重要的,因为它不会过度依赖内存中的数据对象,例如会话和login。

Interesting Posts