I want to make a bash file that automatically runs nodemon and mongod. I have the following code:
#!/usr/bin/env bash
workingDirectory="$(pwd)/"
serverFolder="${workingDirectory}first-app/caffeineOverflow"
cd "${serverFolder}"
mongod &
export caffeine_overflow_jwtPrivateKey=ok
nodemon &
I run it with sudo so that I can run mongod. I get the following error: exception in initAndListen: DBPathInUse: Unable to lock the lock file: /data/db/mongod.lock (Resource temporarily unavailable). Another mongod instance is already running on the /data/db directory, terminating
What should i do in order for this code to run?