2.0 KiB
Work on API Instances
Installing pre-requisites
-
Perform updates to the OS packages by following this guide.
-
Install build tools for node binaries (
node-gyp
) etc.
sudo apt install build-essential
First Install
Provisioning VMs with the Code
-
Install Node LTS.
-
Update
npm
and install PM2 and setup logrotate and startup on bootnpm i -g npm npm i -g pm2 pm2 install pm2-logrotate pm2 startup
-
Clone freeCodeCamp, setup env and keys.
git clone https://github.com/freeCodeCamp/freeCodeCamp.git cd freeCodeCamp
-
Create the
.env
from the secure credentials storage. -
Install dependencies
npm ci
-
Build the server
npm run ensure-env && npm run build:server
-
Start Instances
cd api-server pm2 start production-start.js -i max --max-memory-restart 600M --name org
Logging and Monitoring
pm2 logs
pm2 monitor
Updating Instances (Maintenance)
Code changes need to be deployed to the API instances from time to time. It can be a rolling update or a manual update. The later is essential when changing dependencies or adding enviroment variables.
[!DANGER] The automated pipelines are not handling dependencies updates at the minute. We need to do a manual update before any deployment pipeline runs.
1. Manual Updates - Used for updating dependencies, env variables.
- Stop all instances
pm2 stop all
- Install dependencies
npm ci
- Build the server
npm run ensure-env && npm run build:server
- Start Instances
pm2 start all --update-env && pm2 logs
2. Rolling updates - Used for logical changes to code.
pm2 reload all --update-env && pm2 logs
Note
We are handling rolling updates to code, logic, via pipelines. You do not need to run these commands. These are here for documentation.