NyaSol
NyaSol

Reputation: 567

How to deploy and set a connection between 2 diffrent servers to one Heroku app

Apparently you cannot deploy two different servers to one Heroku app - If I knew that on development I would structure the app differently.

So I have 2 servers server1.js and server2.js - the main reason they are separated is that one of them is a socket.io server and it wouldn't make sense to share the logic in one server.js file.

So what I need to do is to deploy 2 different Heroku apps, and connect both of them to the same Heroku project.

How can I do that? would it make sense to create 2 different git repositors for each server and deploy both of them? and if so how can I make sure that both of them are starting when the dyno starts running?

thank you.

Upvotes: 0

Views: 63

Answers (1)

Samuel Goldenbaum
Samuel Goldenbaum

Reputation: 18919

While we don't have a full picture of the overall solution, there is really is more reason to share logic in a single api and make use of all the same code and resources than there is to keep them separated.

Some thoughts to consider:

  1. Socket.io is happy to be hosted in express.js and is a common architecture.
  2. You have a single codebase that shares common functionality like authentication, sessions, caching etc.
  3. You have a single git repository to keep updated and maintain modules in sync.
  4. You have a single Heroku app to manage and scale horizontally/vertically.
  5. Lower costs by not running multiple apps and less time needed to manage, deploy and update your environment.

The alternative is to keep separate repositories and run separate apps on Heroku as I don't believe you can run multiple buildpacks of the same type within an app.

Upvotes: 1

Related Questions