How to deploy two servers at the same time?

Hello! I am a junior developer and developing a platform through the Parse
I can tell Parse is the best BaaS in the world. I am so proud of you.

Now, I want to deploy a development server for updating the system.
currently, I’ve been working on the production server which is not secure but still works.

But before we started our business I want to separate the server into development and production.
I am using MongoDB located in the same device but It seems I can not perform two parse servers on the one MongoDB.

I am using Node.js to deploy, and my source is over here

let api = new ParseServer({
  databaseURI: server_config.databaseURI, 
  cloud: 'cloud/main.js', 
  appId: server_config.appId,
  masterKey: server_config.masterKey,
  serverURL: server_config.serverURL,
  publicServerURL: server_config.publicServerURL,
  liveQuery: {
    classNames: []
  },
  allowHeaders: ['X-Parse-Installation-Id'],
});

app.use('/api', api);

app.listen(server_config.serverPort, function() {
  console.log(`[ * ] ParseServer on port ${server_config.serverPort}.`);
});

let httpServer = require('http').createServer(app);
httpServer.listen(server_config.serverPort+1, function() {
  console.log(`[ * ] LiveQueryServer on port ${server_config.serverPort+1}`);
});

ParseServer.createLiveQueryServer(httpServer);

I want to use the production Parse server’s directory as [:port/api] and the development directory as [:port/dev]

How can I do? Please help me!

1 Like

The standard (maybe not quickest) solution would be to use a reverse HTTP proxy such as nginx (or any other depending on your preferred environment) to map different combinations of request http ports/paths to different instances of parse server running on the same (or another) machine.

Once you understand the concept of putting a proxy before the running instances, look at building your parse server as a configurable docker image. That will help you spin multiple instances with different configurations (dev prod staging) on the same machine quickly and with predictable release cycle, and you will be well prepared to later migrate to kubernetes.

Questions?
Martin

1 Like

That’s a really good point. I didn’t think of the docker system.
Thanks for commenting!