Skip to main content

Overview

NapCat can be deployed in various production environments. This guide covers deployment methods, environment configuration, monitoring, and security best practices.

Deployment Methods

Using systemd (Linux)

1

Create Service File

Create a systemd service file at /etc/systemd/system/napcat.service:
2

Enable and Start Service

3

View Logs

Using PM2

PM2 is a production process manager for Node.js applications.
1

Install PM2

2

Create Ecosystem File

Create ecosystem.config.js in your NapCat directory:
ecosystem.config.js
3

Start with PM2

4

PM2 Management Commands

Using Docker

1

Create Dockerfile

Dockerfile
2

Create Docker Compose File

docker-compose.yml
3

Deploy with Docker Compose

Environment Variables

Configure NapCat behavior using environment variables:

Available Environment Variables

From napcat.ts:50-58, bypass features can be controlled via environment variable or config file. The bypass system enables protocol optimizations.

Monitoring

Health Checks

Implement health monitoring to ensure service availability:

Log Monitoring

Resource Monitoring

Security Best Practices

Always secure your NapCat deployment in production environments!

1. Network Security

docker-compose.yml

2. File Permissions

3. Authentication

Enable WebUI authentication in your config:
config.json

4. Firewall Configuration

5. Reverse Proxy with SSL

Use nginx as a reverse proxy with SSL:

Backup and Recovery

Backup Essential Data

Automated Backups with Cron

Troubleshooting

Service Won’t Start

High Memory Usage

ecosystem.config.js

Connection Issues

Next Steps

Login Methods

Configure QQ account login

Message Handling

Handle messages and events