Quick Start
The fastest way to run the gateway locally:http://localhost:8787.
From Source Deployment
For production deployments, build and run from source:Development Mode
For development and testing, use the development server:tsx.
Configuration
Environment Variables
Configure the gateway using environment variables:Configuration File
Create aconf.json file for advanced configuration:
conf.json
Process Management
Using PM2
PM2 is a production process manager for Node.js applications.PM2 Ecosystem File
Create anecosystem.config.js file for advanced PM2 configuration:
ecosystem.config.js
PM2 Management Commands
Systemd Service
For Linux systems, create a systemd service:Create Service File
Create/etc/systemd/system/portkey-gateway.service:
portkey-gateway.service
Manage the Service
Reverse Proxy Setup
Nginx
Configure Nginx as a reverse proxy:/etc/nginx/sites-available/portkey-gateway
Add SSL with Certbot
Performance Tuning
Node.js Options
Optimize Node.js for production:Clustering
Utilize multiple CPU cores by running multiple instances behind a load balancer, or use PM2’s cluster mode as shown above.Monitoring
View Logs
Health Check
Check if the gateway is running:Troubleshooting
Port Already in Use
If port 8787 is already in use, change it:Memory Issues
Increase Node.js heap size:Permission Errors
Ensure the user has proper permissions:Next Steps
Docker Deployment
Containerize your Node.js deployment
Configuration
Configure the gateway for production