Skip to content

Multiple apps on one server #116

Description

@samarthagarwal

Hi. I am trying to have multiple apps on one single parse-server deployment. How is it possible?
Since each app will have different app ids, Is it still possible for apps to coincide?

Activity

  1. samarthagarwal commented on Feb 1, 2016

    @samarthagarwal
    Author

    Is connecting each app to a separate mongodb database, a good way to go?

  2. christianmarth commented on Feb 1, 2016

    @christianmarth

    I'm looking at doing the same thing, thinking will need to create a new database and instance of ParseServer for each app and map this to a different path, maybe something like this

    var app1 = new ParseServer({
      databaseURI: 'mongodb://localhost:27017/app1',
      cloud: '/home/app1/cloud/main.js', // Provide an absolute path
      appId: 'myAppId',
      masterKey: 'mySecretMasterKey',
      fileKey: 'optionalFileKey'
    });
    
    // Serve the Parse API on the /parse URL prefix
    app.use('/app1', app1);
    
    var app2 = new ParseServer({
      databaseURI: 'mongodb://localhost:27017/app2',
      cloud: '/home/app2/cloud/main.js', // Provide an absolute path
      appId: 'myAppId',
      masterKey: 'mySecretMasterKey',
      fileKey: 'optionalFileKey'
    });
    
    // Serve the Parse API on the /parse URL prefix
    app.use('/app2', app2);
    
  3. samarthagarwal commented on Feb 1, 2016

    @samarthagarwal
    Author

    So if the client SDK connects to the url /parse, which parse-server instance will actually work? I don't think we should mount both to the same endpoint.

  4. christianmarth commented on Feb 1, 2016

    @christianmarth

    Sorry, i meant also change the url so you have /app1 /app2

  5. samarthagarwal commented on Feb 1, 2016

    @samarthagarwal
    Author

    Do we have any open source dashboard like project that when used with parse-server can give us a Parse like dashboard? Is someone developing it? I am willing to write one myself.

  6. christianmarth commented on Feb 1, 2016

    @christianmarth

    Have a look at #3

    I'm interested in contributing to a dashboard as well, for most of my apps, I've just written a custom CRUD dashboard in Javascript

  7. gfosco commented on Feb 2, 2016

    @gfosco
    Contributor

    Right now the main hurdle for multi-app support will be cloud code. The middleware which creates Parse.Cloud.define/etc will need to be updated similarly to #139 to somehow support separate cloud code initialization. Right now it's easy enough to run multiple from the database side... I'm going to close this for now but hope to see the server hosting multiple apps and cloud code in the not-too-distant future.

  8. jamiechapman commented on Feb 2, 2016

    @jamiechapman

    @gfosco funnily enough I was playing around with the middleware which deals with the Cloud Code functions yesterday (fairly similar to #139).

    I managed to get the functions loaded up for different apps— but the brick wall in the end was the handleCloudFunction method inside functions.js. It's providing difficult to get the current appId at this stage of the request; for some reason req.body at that stage appears to be empty (even though I don't think it should be as bodyParser should have parsed it as JSON like it would in classes.js) — thus exposing _ApplicationId and allowing me to select the right Parse.Cloud function.

    The other issue is the Parse library itself appears to be a global variable, so Parse.applicationId only returns the last defined application — and I guess this probably has a knock-on effect within the Cloud Code itself (e.g. when issuing queries and such?). So I guess that potentially would need some significant refactoring too?

  9. baluragala commented on Feb 20, 2016

    @baluragala

    Does anyone has a workaround for multiple apps with different cloud codes? I have been trying to figure out a way to implement. any quick thoughts please?

  10. christianmarth commented on Feb 21, 2016

    @christianmarth

    Best solution currently is to just create two instances of parse server for now...

  11. kilabyte commented on Feb 21, 2016

    @kilabyte

    You can run the multi instance all in one index and use nodemon to manage the service when for when you makes changes or add another instance.

  12. lowgator commented on Apr 20, 2016

    @lowgator

    Oddly, I have 100+ apps in my parse.com account. Does this mean these are all separate instances of Parse running?

  13. drew-gross commented on Apr 20, 2016

    @drew-gross
    Contributor

    No, parse.com was massively multi-tenant. And as a result, massively complicated. You'll still be able to run your 100 apps on one MongoDB, but you will need separate instances of Parse Server.

  14. lowgator commented on Apr 21, 2016

    @lowgator

    If a separate instance, that means I need to mount each parse instance on its own unique port right? Does Parse offer any consulting services ? I've been struggling all week to get a second app created on my hosted parse server.

  15. 1 remaining item

  16. BrandenSandahl commented on Jul 12, 2016

    @BrandenSandahl

    @drew-gross
    If I am running a parse app by defining a custom index.js style file with my settings and then npm forever-ing it to keep it going, could I potentially just define a whole bunch of different custom index files and run them all, or would there be a better way to do this?

    Hope that makes sense,
    Thanks.

  17. n00r commented on Jul 28, 2016

    @n00r

    i will dynamically create parse server instance like back4app

  18. sowmiyas commented on Sep 14, 2016

    @sowmiyas

    We are planning to have a single mongo db for all our apps by using the collectionPrefix field in parse server. How will this work once we export all data from parse to our own mongo? I am assuming that the export will create separate database for each app and collections will not have a prefix.

  19. georgesjamous commented on Mar 18, 2017

    @georgesjamous
    Contributor

    hello,
    Can someone please clarify this for me. I am new to node and i am a bit lost.
    Regarding running multiple apps...

    I have on my ubuntu system. Parse-server installed in this directory /the directory/myserver/
    The directory looks like this.

    /the directory/myserver/node_modules
    /the directory/myserver/package.json
    /the directory/myserver/application0.js
    /the directory/myserver/application1.js
    /the directory/myserver/application2.js
    

    and each application0.js, application1.js, application2.js
    is on different port. 1337, 1338, 1339

    var express = require('express');
    var ParseServer = require('parse-server').ParseServer;
    var app = express();
    
    var api = new ParseServer({
      databaseURI: 'mongodb://localhost:27017/dev', // Connection string for your MongoDB database
      cloud: '/home/myApp/cloud/main.js', // Absolute path to your Cloud Code
      appId: 'myAppId',
      masterKey: 'myMasterKey', // 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
    app.use('/parse', api);
    
    app.listen(1337, function() {
      console.log('parse-server-example running on port 1337.');
    });
    

    now if i run it this way, could this way be used
    to run multiple apps with cloud code ?

    node application0.js
    node application1.js
    node application2.js
    

    The only way (for now) to run true multiple apps without affecting cloud code and global variables
    is to run them like i did using different processes ?

  20. flovilmart commented on Mar 19, 2017

    @flovilmart
    Contributor

    That seeems correct!

  21. natario1 commented on Jun 8, 2017

    @natario1

    Regarding last comments, has anyone managed to do this in a GAE environment?

    I can run the second app in its own process and port (e.g. 8081), allow the port in app.yaml and in firewall rules, but I see no way to specify the port when requesting myapp.appspot.com. You end up at their load balancer, and it directs to instance:8080 by default. At least, that's what I think is happening 😠

  22. richjing commented on Oct 2, 2017

    @richjing

    take a look on this repo

    • run and manage multiple parse apps (instances) in a server and using a single port.

    • one code, one database, create a parse app in one second.

    • parse dashboard integrated, each app's manager can log into parse dashboard to manage their app.

    • one admin account in parse dashboard to manage all apps

  23. kerbymart commented on Oct 14, 2017

    @kerbymart

    Hello, @flovilmart so it seems with @georgesjam solution it is possible to run multiple parse on one server?

  24. flovilmart commented on Oct 14, 2017

    @flovilmart
    Contributor

    Never said it was impossible, as long as you have each app isolated in it’s own process and a proxy to route to the right local port based on the application ID header.

    I see pm2 has been used to spawn/manage each server process, which is actually a good way of doing so. You could also use pure nginx reverse proxy, docker containers, swarm, containers etc...

    We won’t add multi app tenancy here as it doesn’t make sense, because of the plethora of options for doing so.

    Multi app tenancy could be added by isolating the cloud code process out of parses-server but the performance implications are too high to make it practicle.

  25. kerbymart commented on Oct 14, 2017

    @kerbymart

    @flovilmart anyway the lib/index.js (from https://github.com/parse-community/parse-server) looks totally different from the parse-server-example

  26. flovilmart commented on Oct 14, 2017

    @flovilmart
    Contributor

    What do you mean different? Parse-server-example is just an example usage of parse-server that I don’t recommend to use/fork. I personally use the CLI more and we should deprecate it in favor of the CLI.

  27. brianyyz commented on Oct 14, 2017

    @brianyyz

    @flovilmart can you give a couple of points on why you don't recommend using parse-server-example? I think many people use it as a springboard to get going with Parse and then never leave it.

  28. flovilmart commented on Oct 14, 2017

    @flovilmart
    Contributor

    yeah that's the main reason actually, it's kinda a mess and doesn't encourage a proper way of managing your code either.

    The CLI is powerful enough to accomplish a standalone parse-server. I'm not sure what's the best way to manage it. We're investigating yeoman generators and there's also the bootstrap.sh script that literally sets up a parse server in less than 30 seconds.

    The CLI has the code to start the HTTP server, etc.. it may not fit every single use case, but it's easier to manage than the parse-server-example.

  29. rameshkec85 commented on Aug 29, 2019

    @rameshkec85

    take a look on this repo

    • run and manage multiple parse apps (instances) in a server and using a single port.
    • one code, one database, create a parse app in one second.
    • parse dashboard integrated, each app's manager can log into parse dashboard to manage their app.
    • one admin account in parse dashboard to manage all apps

    Cloud functions are not working in this repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions