Skip to content

Got multiple apps working on one server successfully, why no official support? #1979

Closed

Description

@ahmadhashemi

Like most of Parse.com users, I've got multiple applications running in my Parse account. So I was curious to know if there is any way to do this on a self-hosted parse server or not. After trying different approaches (even running independent server per application, which is a crazy idea!) this is my final configuration which make me able to run multiple applications on one parse server:

var express = require('express');
var ParseServer = require('parse-server').ParseServer;
var path = require('path');

var first = new ParseServer({
  databaseURI: ' ,.',
  appId: ' ,.',
  masterKey: ' ,.',
  serverURL: 'http://localhost:1400/parse',
  cloud:  'cloud/first.js'
});

var second = new ParseServer({
  databaseURI: ' ,.',
  appId: ' ,.',
  masterKey: ' ,.',
  serverURL: 'http://localhost:1400/parse',
  cloud:  'cloud/second.js'
});

var app = express();

app.use('/parse', first);
app.use('/parse', second);

var port = 1400;
var httpServer = require('http').createServer(app);

httpServer.listen(port, 'localhost');

With this configuration inside index.js file, I was able to make both application running on https://mydomain.com/parse and each could be authorized using their own appId and masterKey. Even Cloud Code for each application is working without any problem.

The point is that, why this ability isn't officially documented? Parse developers are saying that running multiple applications on same server isn't supported (Even when I want to run parse-server with terminal command and a configuration for multiple applications, I get an error saying running multiple applications isn't supported). But as I said, I was able to this by editing index.js file in source code like above.

All of these things make me think that I'm missing something. Am I?!

Activity

  1. flovilmart commented on Jun 2, 2016

    @flovilmart
    Contributor

    Concurrent cloud code requests will affect the Parse js SDK and the applicationId won't match.

    There is a big chance that all cloud code requests for your first app will end up affecting your second. So yes, that works only if you don't use cloud code

  2. drew-gross commented on Jun 2, 2016

    @drew-gross
    Contributor

    This issue is asynchronous Cloud Code. The issues will only show up when a) both apps are receiving requests at the same time, and b) your Cloud Code does asynchronous stuff like making queries or writes.

  3. ahmadhashemi commented on Jun 2, 2016

    @ahmadhashemi
    Author

    Oh, now I see. I'd experienced an interesting issue while configuring parse server in my way. Whenever I didn't set serverURL for one of applications, other applications couldn't send requests to their own databases either! (which logically is odd. because one application may use Cloud Code and other may not). So Cloud Code gets broken is some way with this configuration.

    Thank you @flovilmart and @drew-gross for pointing this out. Since hosting multiple applications is more important than using Cloud Code for me, I will abandon Cloud Code for now, and use PHP requests to simulate Cloud Code functionality in my applications.

  4. drew-gross commented on Jun 2, 2016

    @drew-gross
    Contributor

    You could also run multiple parse servers in multiple processes, on different subdomains or ports.

  5. ahmadhashemi commented on Jun 4, 2016

    @ahmadhashemi
    Author

    I missed a little thing. The problem you said about Cloud Code, is it because of using one server for all applications, or sharing /parse as mount path? I mean, can this problem be solved by using exclusive mount path for each application?
    As @flovilmart said, problem is inside Parse JS SDK and I think it has nothing to do with mount path. But I want to make sure.

  6. flovilmart commented on Jun 4, 2016

    @flovilmart
    Contributor

    The JSSDK is a global object, you will encounter problems with your cloud code as soon as you have concurrent calls on your apps.

  7. jkassis commented on Feb 12, 2017

    @jkassis

    @flovilmart @drew-gross My cloud code is running. The only problem seems to be that the internal serverURL is shared so that requests to the cloud API go to the same URL. Can you point me to the singleton object. I'd like to attempt to fix this.

  8. flovilmart commented on Feb 12, 2017

    @flovilmart
    Contributor

    the whole JS SDK is a singleton, probably other parts of parse-server don't play well with multiple apps.

    The only problem seems to be

    That's not the only problem, also your appId, jsKey, context, variables. if another request comes in when processing the previous one from another app, your whole context would get f...d up.

    If you're unsure, please read: #263

    and particularly: #263 (comment)

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