Systemd is an easy way to manage running this web application on a linux system. Another option is running with docker, for those who prefer it.
It's better to follow other, updated instructions, but if you just need to do it quickly:
- Install mongo:
sudo apt update sudo apt install -y mongodb
- Check mongo status. This should show running and you can connect and see the mongo version:
sudo systemctl status mongodb mongo --eval 'db.runCommand({ connectionStatus: 1 })'
- Create a user:
# Connect to your mongo database mongo # Create user db.createUser({ user:'someuser', pwd:'somepassword', roles:[ { role:'readWrite', db:'boardfarm' } ] })
That's it, press CTRL-D to exit.
I recommend running with systemd. These instructions are for Ubuntu.
- Modify the file
sys/bfapi.service
to contain your settings for your mongodb:Environment="MONGO_USER=yourmongouser" Environment="MONGO_PASS=yourmongopass" Environment="MONGO_SERVER=localhost"
- Also change the username and directory path:
User=youruser ExecStart=/path/to/boardfarm_server_api/index.js
- Copy the service file:
sudo cp bfapi.service /lib/systemd/system/
- Reload:
sudo systemctl daemon-reload
- Start the app:
sudo systemctl start bfapi
- You should be able to visit your web app at http://localhost:5001/api
Extra commands:
# Check status
sudo systemctl status bfapi
# See log files
sudo journalctl -u bfapi
# Eanble to automatically run on boot:
sudo systemctl enable bfapi
# Stop the app
sudo systemctl stop bfapi
# Restart the app
sudo systemctl restart bfapi
Another way to run this app is with docker. If you choose to use docker, here's how to set that up.
- Start and setup your mongodb docker container (unless you have it setup somewhere else)
docker run -d -e MONGO_INITDB_ROOT_USERNAME=$adminuser \ -e MONGO_INITDB_ROOT_PASSWORD=$adminpass -p 27017:27017 \ --name mongodb mongo:latest docker exec -it mongodb mongo -u $adminuser -p $adminpass \ --eval "db.createUser({ user:'$bftuser', pwd:'$bftpass', roles:[ { role:'readWrite', db:'boardfarm' } ] })"
- Build the docker container for this project:
docker build -t bft:server_api .
- Start the docker container:
docker run -e MONGO_USER=$bftuser \ -e MONGO_PASS=$bftpass -e MONGO_SERVER=$mongodbserver \ -p 5001:5001 bft:server_api
- You should be able to visit your web app at http://localhost:5001/api