Sign inSign up

negrii/rpp-consumer-node

By negrii

•Updated 8 months ago

Image
0

1.9K

negrii/rpp-consumer-node repository overview

⁠Rustplusplus Consumer Node

Node.js consumer for RabbitMQ that processes Rust+ smart alarm events generated by the Rust game and logs them in a structured format.


⁠Features

  • Connects to RabbitMQ
  • Consumes alarm events from Rust+ smart devices published by rustplusplus⁠, a fork with built-in RabbitMQ publishing
  • Logs full event payloads
  • Prometheus metrics integration for monitoring
  • Graceful shutdown handling (SIGINT / SIGTERM)
  • Fully Dockerized
  • Ready for production usage

⁠Event example

{
  "active": false,
  "reachable": true,
  "everyone": true,
  "name": "YOUR BASE IS UNDER ATTACK",
  "message": "YOUR BASE IS UNDER ATTACK",
  "lastTrigger": 1567870268,
  "command": "317829368",
  "id": "357925331",
  "image": "smart_alarm.png",
  "location": "T13",
  "server": "Rusty Moose |EU Main|",
  "messageId": "1453794030969426105"
}

⁠Prometheus Metrics

The application includes built-in Prometheus metrics for monitoring alarm events. Metrics are exposed on a dedicated HTTP endpoint when enabled.

⁠Configuration

Enable metrics by setting environment variables:

METRICS_ENABLED=true
METRICS_PORT=9100

Metrics endpoint: http://localhost:9100/metrics

⁠Available Metrics
⁠rust_alarms_total

Counter of the total number of alarms received since the application started.

this.alarmsTotal = new Counter({
    name: 'rust_alarms_total',
    help: 'Total number of alarms received',
})

Type: Counter
Labels: None


⁠rust_alarms_by_server

Alarm counter grouped by server. Allows you to track which servers generate the most alarms.

this.alarmsByServer = new Counter({
    name: 'rust_alarms_by_server',
    help: 'Server alarms',
    labelNames: ['server'],
})

Type: Counter
Labels: server


⁠rust_alarms_by_day

Alarm counter grouped by day. Useful for analyzing temporary trends.

this.alarmsByDay = new Counter({
    name: 'rust_alarms_by_day',
    help: 'Alarms per day',
    labelNames: ['date'],
})

Type: Counter
Labels: date


⁠Prometheus Scrape Configuration

Add this job to your prometheus.yml:

scrape_configs:
  - job_name: 'rpp-consumer-node'
    static_configs:
      - targets: ['rpp-consumer-node:9100']

ā šŸ“¦ Available Images

⁠Docker Hub
docker pull negrii/rpp-consumer-node:latest
⁠GitHub Container Registry
docker pull ghcr.io/negri234279/rpp-consumer-node:latest

Also available by version:

v1.0.0
v1.0.1
v1.1.0

ā šŸš€ Quick start with Docker Compose

⁠1ļøāƒ£ 🧠 Environment variables
VariableDescriptionDefault
RABBITMQ_HOSTRabbitMQ host-
RABBITMQ_PORTRabbitMQ port-
RABBITMQ_USERRabbitMQ username-
RABBITMQ_PASSWORDRabbitMQ password-
METRICS_ENABLEDEnable Prometheus metrics (true/false)false
METRICS_PORTPort for Prometheus metrics endpoint9100
TZTimezone for logs (IANA timezone database⁠)Europe/Madrid
LOCALEUnicode BCP 47 locale identifier for formattinges-ES
ā ā„¹ļø About LOCALE

The LOCALE variable uses the Unicode BCP 47 locale identifier standard (Unicode TR35⁠). This determines how dates, times, and numbers are formatted in logs.

Common values:

  • es-ES - Spanish (Spain)
  • en-US - English (United States)
  • en-GB - English (United Kingdom)
  • fr-FR - French (France)
  • de-DE - German (Germany)
  • pt-BR - Portuguese (Brazil)

Format example with es-ES:

[31/12/2025 23:45:30] [INFO] Smart alarm processed for server: Rustopia

Format example with en-US:

[12/31/2025 11:45:30] [INFO] Smart alarm processed for server: Rustopia

⁠2ļøāƒ£ Run container
docker run -d \
  --name rpp-consumer-node \
  --env-file .env \
  --restart unless-stopped \
  -v rpp-consumer-node-logs:/app/logs \
  negrii/rpp-consumer-node:latest

⁠3ļøāƒ£ docker-compose.yml
services:
  rpp-consumer-node:
    image: negrii/rpp-consumer-node:latest
    container_name: rpp-consumer-node
    ports:
      - '9100:9100' # Expose to the host the prometheus metrics
    env_file:
      - .env
    restart: unless-stopped
    volumes:
      - rpp-consumer-node-logs:/app/logs

  # If enable the prometheus metrics
  rpp_prometheus:
    container_name: rpp_prometheus
    image: prom/prometheus:latest
    restart: unless-stopped
    ports:
      - '9090:9090'
    volumes:
      - ./prometheus.yml:/etc/prometheus/prometheus.yml:ro
      - rpp_prometheus_data:/prometheus
  
volumes:
  rpp-consumer-node-logs:

⁠4ļøāƒ£ Start service
docker compose up -d

View logs:

docker logs -f rpp-consumer-node

ā šŸ—‘ļø Remove container and volume (full reset)
docker rm -f rpp-consumer-node
docker volume rm rpp-consumer-node-logs

āš ļø This will remove all persisted state.


ā šŸ—ļø Development

docker compose -f 'docker-compose.dev.yml' up -d --build

ā šŸ”„ CI/CD

This project uses GitHub Actions for:

  • Automatic versioning with semantic-release
  • Creation of GitHub Releases
  • Multi-arch builds with Docker Buildx
  • Automatic push to Docker Hub and GHCR

Each push to main generates a new version if the commits require it.


ā šŸ” Security

  • Container run as non-root user

ā šŸ‘¤ Author

Negrii šŸ”— https://github.com/Negri234279⁠


ā šŸ“„ License

MIT License


⁠⭐ Contributions

Pull requests and suggestions are welcome šŸ™Œ

If you find this project useful, leave a ⭐ on GitHub

Tag summary

Content type

Image

Digest

sha256:03f11ec17…

Size

80.6 MB

Last updated

8 months ago

docker pull negrii/rpp-consumer-node