-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
adds support for multiple apps on a single server #263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
flovilmart
commented
Feb 5, 2016
- Adds support for loading configuration from JSON
- Adds support for loading multiple configurations from ENV
- Adds generator for new app keys
- Adds support for cloud code isolated processes
- Adds cloud code runner / launcher
- Full /hooks REST API (only master)
- Parse.Hooks: register hooks on nodejs/cloud code server
- Parse.Cloud with automatic hooks registration (from parse-cloud-express)
- Customizable hook registration strategy for cloud code server (always, try, never)
- All unit tests are running in a multiple apps context
@flovilmart updated the pull request. |
Hey, thanks for the pull request, but I don't think we will be able to accept this, as it will interfere with our implementation of Cloud Code and our (upcoming) implementation of push. We could look at how we would support this again after push lands. We would also need to test this change very thoroughly. |
Cloud code would work the same as the path is provided per application. |
As @gfosco explained to me, the issue is not the paths for the cloud code, but rather that the implementation of cloud code modifies global variables, so the cloud code from one app could affect the other apps. If you can write some tests that verify that this works with cloud code, and also wait until our push implementation is ready and write some tests to make sure that works as well, we could probably accept this. |
In that case i would add process isolation for cloud code like i did In https://github.com/flovilmart/parse-anywhere so the environment of cloud code remain 'stable' |
That seems to be a good time to also bring back the REST API hooks for cloud code. This way we ensure isolation of cloud code in a subprocess and use that API to make the calls. |
@flovilmart updated the pull request. |
actually @drew-gross @gfosco the main problem is the Parse JS SDK here that is completely stateful, and the architecture that is semi stateful. We leverage global variables across the different parts when we should rely only on request parameters (mostly for triggers.js and functions.js). I'd need to make a Parse SDK that could generate new instances, or factory instances per AppID, and attache the instance to the expressjs request in a middleware, this way, instead of using a global Parse object, we'd use a local Parse object per request. |
Factory instances for the Parse SDK sounds like a good idea to me. |
That imply a quite big refactor, just looked today, as the JS SDK is completely architectured around the CoreManage 'singleton'. |
@flovilmart updated the pull request. |
Yeah, I suspected it would be :( and given that it's pretty easy to just run another instance of parse-server for your other apps, it's probably not worth it. We can try to keep it in mind when editing the current code though, and maybe it's something we can eventually support. |
The latest version is 'stable'. When using require, the developer should make a particular effort to call I most probably should call Parse.initialize before each hook call to force the Parse singleton. What do you think? |
@flovilmart updated the pull request. |
I'll still have to check with our push team to see what conflict might exist with our push implementation, as I know they were worried about having multiple apps on the same server. Thanks a lot for writing tests :) Reinitializing the Parse JS SDK at the appropriate times sounds like it might be a good solution to global state problems, and we use that solution in the Parse Dashboard, but with multiple requests happening at once in Node.js, that might not end up being enough. Race condition tests sounds like a good idea. |
I'll check the push implementation in that case as I rebased recently and it's there on that branch. |
The solution for cloud code would be to isolate it in it's own subprocess, this way the parse would be on it's one. |
// Specify the connection string for your mongodb database | ||
// and the location to your Parse cloud code | ||
var api = new ParseServer({ | ||
databaseURI: 'mongodb://localhost:27017/dev', | ||
cloud: '/home/myApp/cloud/main.js', // Provide an absolute path | ||
appId: 'myAppId', | ||
<<<<<<< 9a14f53e45c29b4fd0c530ea23194fc33ce45f7f |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe this is a mistake :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep... That's a rebase error... Still working on Cloud Code :)
@flovilmart updated the pull request. |
@drew-gross I managed to isolate the Cloud code runs in the case of multiple apps, or if specified like that. Now I need to add a persistence layer for the hooks URL's otherwise upon server restart, we loose all the mapping. The subprocess is there by default for the multiple apps case, so it is safe. The implementation relies on parse-cloud-express (because it makes sense). Calling any Parse.Cloud.[define, beforeSave, afterSave, beforeDelete, afterDelete] in the subprocess environment will update the hook asynchronously, and following the Parse REST API. A developer can also generate a clean Cloud Code environment on a 3rd party server with:
This should be safe for cluster configuration of cloud code. The triggers Api is pretty much unchanged, the network calls are wrapped into the trigger itself. On that, should we load all hooks in memory upon server start or for each request? |
@flovilmart updated the pull request. |
@gfosco I'll need a PR for that : https://github.com/ParsePlatform/parse-cloud-express/pull/17 to clean up some code |
@flovilmart updated the pull request. |
1 similar comment
@flovilmart updated the pull request. |
@@ -1,5 +1,3 @@ | |||
var Parse = require('parse/node').Parse; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needed to remove that import because of parse-cloud-express and conflicting dependencies.
@flovilmart updated the pull request. |
And I just had an epiphany... We can leverage heroku Procfile in order to let the cloud code process externally managed.
|
Sadly it is looking more and more like multiple-app support won't make it in to the core repo.. If you're okay with closing this for now @flovilmart, I'd like to keep things clean. |
@gfosco definittely, we're 3 scripts away from supporting it as I decoupled all pieces. The 1st iteration would be experimental, without 'internal' cloud code support. |
Hey guys, I just have read the whole conversation and I totally agree with @flovilmart reasons to support multiple apps. I would really love to see this coming to light. Just wanted to show my affection for this feature. Great work @flovilmart ! |
Any news about multi-app support? Would be a great feature! |
Hi! How is multi-app support going? |
Any updates on multiple app support? |
no update and it's unlikely it will be any update coming from me |
our project also conside multi-tenancy recently, Any updates on multiple app support? |
Still haven't changed, and it is unlikely to. |
@flovilmart the node.js now support vm which provides APIs for compiling and running code within V8 Virtual Machine contexts. Could it support the multiple app feature by using those apis? |
No it won't, the context need to be isolated from the main process. It's been extensively discussed before, tried and failed. The only solid solution is to spawn subprocesses either for the full cloud code or for each function call, which is costly and inefficient. |
thank for your answer. I will do some try by using pm2 to manage mutiple paser-server instances. Maybe the solution is not in paser-server itself. |