I am a total beginner in shell scripting.
I have a node js program, and an API, which uses mongoDB. So the API uses express and is linked to my routes and schemas - all I have to do in order to start the API server is run node app.js
However, I also have my main program, which polls specific urls that the user adds through the database, and then saves the data that is returned from the poll request in the database. This happens every 'x' seconds, therefore I always open the mongo connection when the poll happens, and close it as soon as it finishes it. So in order to run this program, I need to run node main.js
The app.js seems to just open the mongo connection once, when the program is run.
So my question is - can I link them together somehow by writing a bash script so I can start both of the processes together and end them when needed?
I tried doing this:
#!/usr/bin/bash
# declare STRING variable
STRING="Starting node processes"
#print variable on a screen
echo $STRING
node misrepo/app.js
node misrepo/main.js
However this only starts the app.js, and does not run my main.js application.
Any help would be appreciated as I am just trying to figure this out from googles help!