# install mongo db, access shell
mongo
# create admin account
use admin
db.createUser(
{
user: "devAdmin",
pwd: passwordPrompt(), // or cleartext password
roles: [ { role: "userAdminAnyDatabase", db: "admin" }, "readWriteAnyDatabase" ]
}
)
# check for admin account
db.getSiblingDB('admin').system.users.find()
# shutdown
db.adminCommand( { shutdown: 1 } )
# add auth to mongo conf
vi /usr/local/etc/mongod.conf
security:
authorization: "enabled"
# restart service
sudo systemctl restart mongod
git clone <repo>
# install dependencies
npm install
# install pm2
npm install pm2 -g
# update env, follow instructions in example file
# make sure to strong secret, admin password
cp .env.sample to .env
# add mongodb url to the env, replace with username and password from above
mongodb://<user>:<pwd>@127.0.0.1:27017/<db>?authSource=admin
# starting the server
pm2 start ecosystem.config.js
# by default the server is forked by no of CPU cores, load balanced by pm2
# to change that, update the instances value in ecosystem file.
# to monitor
pm2 monit
# logs
pm2 logs
# create admin account after setting up client and server
curl <server_url>/api/auth/init
# cd to the repo folder
git pull origin master
# install dependency changes
npm install
# restart servers
pm2 restart all