Nija

NIJA Bot Restart Guide

This document explains how to restart the NIJA trading bot.

Overview

NIJA provides two methods for restarting the bot:

  1. Web Dashboard API - Restart via HTTP endpoint
  2. Command-line Script - Restart via shell script

Both methods perform a graceful shutdown by sending a SIGTERM signal to the bot process, allowing it to close positions and clean up resources before the deployment platform automatically restarts it.

Method 1: Web Dashboard API

Endpoint

POST /api/restart

Usage with curl

curl -X POST http://localhost:5001/api/restart

Response (Success)

{
  "success": true,
  "message": "Restart signal sent to NIJA bot",
  "pid": 12345,
  "timestamp": "2026-01-21T20:45:00.000Z"
}

Response (Bot Not Running)

{
  "success": false,
  "message": "Bot process not found - it may not be running",
  "timestamp": "2026-01-21T20:45:00.000Z"
}

Response (Error)

{
  "success": false,
  "error": "Error message here",
  "timestamp": "2026-01-21T20:45:00.000Z"
}

Method 2: Command-line Script

Usage

./restart_nija.sh

Example Output

==============================
  RESTARTING NIJA TRADING BOT
==============================
Found NIJA bot process: PID 12345
Sending SIGTERM signal for graceful shutdown...
✅ Restart signal sent
   The deployment platform will automatically restart the bot

To check if the bot restarted successfully:
  tail -f nija.log

How It Works

  1. The restart mechanism finds the running bot.py process
  2. Sends a SIGTERM signal to the process
  3. The bot handles the signal gracefully (see bot.py line 135-137):
    • Closes open positions (if configured to do so)
    • Saves state to disk
    • Exits cleanly
  4. The deployment platform (Railway/Render) detects the process exit
  5. The platform automatically restarts the bot using the configured start command

Platform-Specific Behavior

Railway

Render

Docker

When to Use Restart

Restart the bot when you need to:

Monitoring the Restart

After triggering a restart, monitor the bot logs:

# Watch live logs
tail -f nija.log

# Check recent logs
tail -100 nija.log

Look for the startup banner:

======================================================================
NIJA TRADING BOT - APEX v7.1
Branch: main
Commit: abc1234
======================================================================

Troubleshooting

“Bot process not found”

This means the bot is not currently running. Start it with:

./start.sh

Bot doesn’t restart automatically

Check your deployment platform’s restart policy configuration:

Restart is taking too long

The bot may be waiting for:

Give it 30-60 seconds before checking the logs.

Security Considerations

The /api/restart endpoint should be protected in production environments:

See Also