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:
- a separate terminal window for running MongoDB
- a separate terminal window for running the Node.Js server
- 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
- 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. saidshahahmadi2016@gmail.com