CIRCE / DOCUMENTATION
Node.js and pm2
Run Circe on Node.js 22+ with pm2 or systemd, with Docker and Kubernetes variants.
On this page
Prepare the project
On Node.js 22.18 or later Circe runs your TypeScript directly, so there is no build step.
npx @sxnnyside/circe init --runtime node --standard
npm install
cp .env.example .env # then fill in the values
npx circe doctor
npx circe dev # local development with restart on change
Production install without dev tools:
npm ci --omit=dev
npx circe build # validates config and modules, no Discord connection
npx circe start
pm2
pm2 keeps the bot alive, restarts it on crashes and manages logs.
npm install -g pm2
Create ecosystem.config.cjs in the project root:
module.exports = {
apps: [
{
name: "circe-bot",
script: "npx",
args: "circe start",
interpreter: "none",
env: { NODE_ENV: "production" },
restart_delay: 3000,
max_restarts: 10,
kill_timeout: 12000, // longer than shutdownTimeoutMs (default 10000)
},
],
};
Circe reads .env from the project folder, so you do not need to pass secrets through pm2.
pm2 start ecosystem.config.cjs
pm2 logs circe-bot # follow logs
pm2 restart circe-bot # after deploying new code
pm2 save # remember the process list
pm2 startup # start pm2 on boot (follow the printed command)
pm2 stop and pm2 restart send SIGINT, which circe start handles by disconnecting cleanly. kill_timeout gives that shutdown time to finish before pm2 force-kills.
Do not run
circe devunder pm2.devrestarts on file changes and is for local work only.
systemd
# /etc/systemd/system/circe-bot.service
[Unit]
Description=Circe Discord Bot
After=network.target
[Service]
Type=simple
User=botuser
WorkingDirectory=/opt/circe-bot
ExecStart=/usr/bin/npx circe start
Restart=on-failure
RestartSec=5s
TimeoutStopSec=15
EnvironmentFile=/opt/circe-bot/.env
[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable --now circe-bot
sudo journalctl -u circe-bot -f
HTTP interactions on Node
With transport: "http" or "hybrid", Circe serves interactions on a built-in node:http bridge and verifies Ed25519 signatures with Node’s crypto.subtle. Put it behind HTTPS and paste the URL in the Developer Portal. See Transports.
Docker
FROM node:22-slim AS runner
WORKDIR /app
ENV NODE_ENV=production
COPY package.json package-lock.json ./
RUN npm ci --omit=dev
COPY circe.config.ts ./
COPY src ./src
# Only needed for transport "http" or "hybrid", or health checks
EXPOSE 8787
CMD ["npx", "circe", "start"]
docker build -t circe-bot .
docker run -d --name circe-bot --restart unless-stopped --env-file .env -p 8787:8787 circe-bot
Kubernetes
Gateway bots are one stateful session per token: use replicas: 1. Only transport: "http" bots scale horizontally behind a Service with TLS.
apiVersion: apps/v1
kind: Deployment
metadata:
name: circe-bot
spec:
replicas: 1
selector:
matchLabels: { app: circe-bot }
template:
metadata:
labels: { app: circe-bot }
spec:
containers:
- name: bot
image: my-registry/circe-bot:latest
command: ["npx", "circe", "start"]
envFrom:
- secretRef: { name: circe-bot-secrets }
livenessProbe:
httpGet: { path: /health, port: 8080 }
readinessProbe:
httpGet: { path: /ready, port: 8080 }
The probes assume health: { port: 8080 } in circe.config.ts.
SQLite on Node
SqliteCooldownStore uses the built-in node:sqlite module on 22.18+, so there is nothing native to compile. It is still marked experimental upstream by Node.js.
