Deployment
Prerequisites
The website depends on the Sensor Server and Digital Hospital Server to be running. The details of running the digital hospital server can be found in the repository of the digital hospital server (opens in a new tab) (it is built by Yin-Chi)
Eco System File
We use pm2 to run the website and the sensor server in a production environment. The configuration file for pm2 is ecosystem.config.js. This spins up both services and runs them on different ports in detached mode.
const prodEnv = {
WEB_PORT: 2222,
SENSOR_PORT: 7777,
DH_PORT: 5000, // Can not be configured on this file
};
const devEnv = {
SENSOR_PORT: 8000,
DH_PORT: 5000, // Can not be configured on this file
};
...Note: The
DH_PORTis not configurable in this file. It is set in thedocker-compose.ymlfile in the digital hospital server (opens in a new tab) repository.
The devEnv is used to set the ports for the sensor server when running in development mode. The website uses these ports in dev. Note you can not change the port that the website runs in development using this file. To do that you have to go into the web directory and run
PORT=<PORT> pnpm startUse this to change the ports of the servers if you are running them on different ports.
Pre Deployment
web
Build the website by cd into the web directory and run
pnpm buildservers/sensor
Ensure you have a virtual environment set up using the folder name venv, it is important that the folder is called venv as the ecosystem file looks for this folder. Then install the packages in the requirements.txt file.
pip install -r requirements.txtRunning
Ensure you have pm2 installed globally
npm install -g pm2Then run
pm2 start ecosystem.config.jsThis will run the website and the sensor server in detached mode. You can view the logs of the services by running
pm2 logsYou can monitor the services by running
pm2 monitStopping
To stop the services run
pm2 stop ecosystem.config.jsRestarting
To restart the services run
pm2 restart ecosystem.config.jsDelete
To delete the services run
pm2 delete ecosystem.config.js