Vidly-api-node : how do I run multiple services at the same time

I was wondering how to run multiple services at the same time?

For the Vidly app to interact with the Mongo DB you need to have the Mongo DB running, the Node server running, and your app running. If I start any one of these services up, my terminal cursor is not returned until I stop the service with CONTROL-C.

For reference, the following are the three services:
MogoDB service

mongod --config /usr/local/etc/mongod.conf

The Node.js server (in the directory ~/vidly-api-node)

node index.js

The vidly React application (in the directory ~/vidly)

npm start

The easiest solution is to use multiple terminal windows:

  1. a separate terminal window for running MongoDB
  2. a separate terminal window for running the Node.Js server
  3. a separate terminal window for running the React.Js client

These could be terminal windows for your OS, or they could be terminal windows in your editor (such as VS Code).

What OS are you running? I am running Windows and MongoDB starts in the background for me as a service when the OS starts.

Thanks ekinated. I am running this on a Mac and used three separate terminal windows, one for each item. I was hoping that there was a more elegant solution.

You can use an npm package like “concurrently” to run multiple commands at once in the same terminal window, BUT then the console output (errors, debugging info) will all be in a single window and you’re going to have a harder time reading that information if an error happens.

You can setup MongoDB to run automatically when your machine boots, but if you only use it while you’re actively developing, it might not be worth it because it will use resources.

1 Like

I also forgot (because I’m not on Mac OS / Linux / Unix), that you can run programs in the background by appending the & ampersand character to your command. You just won’t see any of the debug/error info, and you’ll have to remember to manually kill the background process.

1 Like

:man_facepalming: - I want to feel really stupid since I’ve been programming on a Mac for over 10 years, but honestly I haven’t had a need to do this until now since I’ve always been connecting to other resources.

I’ve always just done separate terminal windows, so that if an error occurs or I need to check some information that I wrote to the console, I can easily just check the specific terminal window (API Server or React Web Front-end). On my machine, I don’t have a separate terminal window for MongoDb, because it’s set to run as a Windows Service when my machine boots up.

If there is a more elegant solution, I’m interested to learn about it.

Can someone send me the React Native Node.js Files .in react native part 2. In the networking folder.

The Node.js file

This is my email address.