-
-
Notifications
You must be signed in to change notification settings - Fork 0
PM2 Setup
Amit Das edited this page Apr 28, 2026
·
1 revision
This guide explains how to run SecureAuth using PM2.
PM2 is a production process manager for Node.js applications that helps keep SecureAuth running continuously.
Benefits of PM2:
- Automatic restarts
- Crash recovery
- Process monitoring
- Background execution
- Startup on server reboot
Before starting:
- Node.js installed
- npm installed
- SecureAuth project configured
Install PM2 globally.
npm install -g pm2pm2 -vcd SecureAuthEnsure .env is properly configured.
Example:
# ===============================================
# SecureAuth - ENVIRONMENT CONFIGURATION
# ===============================================
APP_NAME="SecureAuth"
APP_URL="https://example.com"
# TEXTSNAP CONFIG
TEXTSNAP_INSTANCE_ID="YOUR_INSTANCE_ID"
TEXTSNAP_ACCESS_TOKEN="YOUR_ACCESS_TOKEN"
# FIREBASE CONFIG
FIREBASE_DATABASE_URL="YOUR_FIREBASE_DATABASE_URL"
FIREBASE_DATABASE_SECRET="YOUR_FIREBASE_DATABASE_SECRET"
# SECURITY CONFIG
JWT_SECRET="YOUR_SECRET_KEY"
ENCRYPTION_KEY="YOUR_ENCRYPTION_KEY"Before starting production server:
npm run buildRun SecureAuth using PM2.
pm2 start npm --name secureauth -- startpm2 listView application logs.
pm2 logs secureauthpm2 restart secureauthpm2 stop secureauthpm2 delete secureauthSave active processes.
pm2 saveEnable PM2 startup on server reboot.
pm2 startupRun the command PM2 provides after execution.
Open PM2 monitoring dashboard.
pm2 monitCreate ecosystem config file.
Example:
module.exports = {
apps: [
{
name: "secureauth",
script: "npm",
args: "start",
cwd: "/path/to/SecureAuth",
env: {
NODE_ENV: "production"
}
}
]
}pm2 start ecosystem.config.cjspm2 reload secureauthRecommended architecture:
Client
↓
Nginx Reverse Proxy
↓
PM2 Managed SecureAuth Process
↓
Authentication & API HandlingFor production:
- Use HTTPS
- Restrict server access
- Use strong environment secrets
- Monitor logs regularly
Check logs:
pm2 logs secureauthCheck port usage:
lsof -i :3000Restart app:
pm2 restart secureauthReinstall globally:
npm install -g pm2Test locally:
curl http://127.0.0.1:3000PM2 should be combined with Nginx for:
- Reverse proxy support
- HTTPS handling
- Better security
Continue with:
Secure • Fast • Modern ⚡
SecureAuth
Secure • Fast • Modern ⚡