Skip to content

g4-api/g4-bot-monitor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚀 Quick Start: G4 Bot Monitor

Build, Test & Release G4™ Bot Monitor

g4-bot-monitor is a lightweight, single-file SignalR client designed to shadow a bot and sync its status to a central SignalR hub. It also exposes a tiny HTTP listener so the bot can report its own status via local HTTP requests.


⚙️ CLI Usage

g4-bot-monitor --HubUri=<hub-url> --Name=<bot-name> --Type=<bot-type> --ListenerUri=<listener-url> --Id=<bot-id>

All parameters are required:

Parameter Description
--HubUri SignalR hub URL (e.g., http://localhost:9944)
--Name Human-readable bot name (e.g., "InvoiceBot")
--Type Bot type/category (e.g., "Static Bot", "File Listener")
--ListenerUri Base URI where the monitor listens (e.g., http://localhost:8080)
--Id The unique identifier of the bot instance used for hub registration and tracking.

📡 HTTP Listener Endpoints

After startup, the monitor begins listening at:

<ListenerUri>/monitor/<Id>/

✅ 1. GET /monitor/ping

Simple health check — always returns 200 OK.

curl http://localhost:8080/monitor/ping

Response:

{ "message": "pong" }

📤 2. POST /monitor/update

Used by the bot to send status updates to the SignalR hub.

Expected payload:

{ "status": "Working" }

Example request:

curl -X POST http://localhost:8080/monitor/update \
     -H "Content-Type: application/json" \
     -d '{ "status": "Working" }'

Success Response:

{ "message": "Connected bot successfully updated." }

Failure Response:

{
  "error": "ExceptionType",
  "message": "Stack trace or reason"
}

🧪 Full Example

./g4-bot-monitor-linux-x64 \
  --HubUri=http://localhost:9944 \
  --Name=Bot42 \
  --Type="Static Bot" \
  --ListenerUri=http://localhost:8080 \
  --Id=1234567890

✅ Runtime Behavior

  • Retries connection and registration up to 10 minutes
  • Exposes /monitor/ping and /monitor/update endpoints
  • Listens for ReceiveHeartbeat and ReceiveRegisterBot from the hub
  • Handles Ctrl+C, shutdown signals, and graceful cleanup
  • Skips failed update attempts (non-blocking)