Developer Documentation

Everything you need to configure, package, and deploy your bots stably on Kraftbot.

1GitOps Deployment

Kraftbot operates on a GitOps model. Your bot's code is directly connected to your GitHub repository.

Automatic Deployment

Every time you push to your main branch (git push), Kraftbot automatically builds a new container image of your bot and deploys it instantly.

Isolated Infrastructure

Your bots run in isolated, secure containers (no shared VM resources or fragile PM2 background scripts).

2Repository Structure & Runtimes

The platform automatically detects your bot's language and dependencies during the initial repository import.

Supported Native Runtimes

Node.jsVersions 18, 20+

Detected if your repository contains a package.json file with dependencies such as discord.js or @slack/bolt.

// Default startup command:
npm start (if defined in package.json) or node index.js
PythonVersions 3.10, 3.11+

Detected via the presence of a requirements.txt, Pipfile, or pyproject.toml containing bot dependencies (such as discord.py).

// Default startup command:
python main.py or python bot.py

Custom Startup Command (Procfile)

If your bot's entry point is located in a specific folder, add a file named Procfile to the root of the repository:

bot: node dist/src/main.js

Note: Kraftbot uses the "bot:" key to identify the main process to execute.

3Secrets & Environment Variables

Never commit your access tokens or API keys (such as your DISCORD_TOKEN) to GitHub.

shield
Enhanced SecurityYour API keys are stored in a highly encrypted format by the platform. They are injected into the bot container at runtime, without ever touching your source code.

Define your variables in your bot's dashboard:

  • Secrets (encrypted and masked, e.g., DISCORD_TOKEN, DATABASE_URL)
  • Public variables (configured in plain text, e.g., LOG_LEVEL, PREFIX)

They are read in your source code using standard methods:

// Node.js (JavaScript / TypeScript):
const token = process.env.DISCORD_TOKEN;
// Python:
import os
token = os.getenv('DISCORD_TOKEN')

4Lifecycle: Build & Deployment

Secure Build

Upon pushing, a temporary container compiles your code. Production dependencies are installed, and the final image is pushed to our secure private container registry.

Double-Connection Prevention Strategy (Recreate)

If two instances of your bot attempt to connect to the Discord Gateway at the same time, access is rejected. Kraftbot solves this using a Recreate strategy: the old version of the bot is completely disconnected before the new instance starts.

Graceful Shutdown

During an update, a SIGTERM signal is sent to your bot. Kraftbot grants it a **10-second grace period** to close database connections and disconnect from the Discord gateway.

// Example of graceful shutdown in Node.js
process.on('SIGTERM', async () => {
  console.log('SIGTERM signal received. Shutting down...');
  await client.destroy(); // Disconnect Discord client
  process.exit(0);
});

Resource Quotas

Each container has default resource limits to ensure overall infrastructure stability:

PROCESSOR (CPU)0.5 Cores
MEMORY (RAM)512 MB

5Monitoring, Logs & Rollbacks

Kraftbot integrates all the necessary tools for the operational tracking of your application:

terminal

Real-time Logs

Access the standard console output (stdout/stderr) of your bot to trace connection logs or intercept error messages on the fly.

history_toggle_off

1-Click Rollback

Did an update cause a crash? Cancel the deployment by instantly reverting to a stable previous version in less than 10 seconds right from your dashboard.