Server Details
Hellonext
Production FE Server IP: 34.168.209.96
Staging FE Server IP: 139.59.82.13
Production API Server IP: 34.168.209.96
Staging API Server IP: 139.59.82.13
Production Meilisearch Server IP: 35.235.102.36
Staging Meilisearch Server IP: 139.59.82.13
PM2 Servers
We use PM2 for our deployment of NodeJS based apps and also as app servers for the same.
Restart Strategies
Manual restart of all the services
This will restart all the services saved via pm2 save
pm2 resurrectDuring Crisis Manual Restart of NextJS Project
This will start the services in specific folders. We should run this only when resurrect is not helping.
Make sure this is only the last resort
# Example in Huracan
cd /var/www/huracan/current
pm2 start ecosystem.staging.config.jsDeployment Strategies
Via Github Actions
By default all the NextJS deployments happens via Github Actions where the environment is already set. Github actions can be triggered via an iOS Shortcuts by @karthik or @varun
Via PM2 Script
The other way to deploy apps is manually from the developer machines, for this we need the following things configured in one’s machine
SERVER_HOSTenv in .env file- Server host should be added in ssh known host
- The deploying machine’s SSH certificate must be added in server
If all the above is set, we can do the deployment via the following script (_shown example for Hellonext)
cd projects/Huracan # Where your project folder in your machine
pm2 deploy ecosystem.staging.config.js productionConfig and Log File Locations
Caddy Config File: /etc/caddy/Caddyfile
Caddy Log File: /var/log/caddy/access.log
PM2 Log Files: /home/deploy/.pm2/logs/
Commands
Restarting Caddy
sudo systemctl reload caddyRestarting PM2 Services
# For Indivudual Process
pm2 restart <PROCESS_NUMBER>
# For All Process
pm2 restart all