Skip to content

Send POST requests to an endpoint on podping updates.

License

Notifications You must be signed in to change notification settings

SilasVt/podpingd-post

 
 

Repository files navigation

podpingd-post

This project combines podpingd (a program that monitors the Hive blockchain for podcast updates) with a Node.js watcher that forwards these updates to an API endpoint as a POST request.

Components

  • podpingd: Monitors the Hive blockchain and writes JSON files for each podping
  • Node.js watcher: Monitors the JSON files and forwards them to a configured API endpoint

Configuration

Copy the example environment file and modify it to your needs:

cp .env.example .env

Available environment variables:

# Directory where podpingd writes JSON files
WATCH_DIR=/app/data

# API endpoint for sending podping notifications
TARGET_ENDPOINT=http://your-api-endpoint/api/podping

# Request configuration
MAX_CONCURRENT_REQUESTS=5      # Maximum concurrent HTTP requests
REQUEST_TIMEOUT_MS=30000       # HTTP request timeout in milliseconds
REQUEST_RETRY_COUNT=3          # Number of retries for failed requests
REQUEST_RETRY_DELAY_MS=3000    # Delay between retries in milliseconds

# File monitoring configuration
FILE_AGE_TIMEOUT_SEC=60        # Restart podpingd if no new files in this period

# Podpingd configuration
CONFIG_FILE=/app/conf/post-config.toml  # podpingd config file location
RESTART_MINUTES=3              # How far back to set start_datetime when restarting
MAX_CONSECUTIVE_FAILURES=5     # Restart after this many consecutive HTTP failures

Running with Docker

Build and run the container:

docker build -t podpingd-post .
docker run -d \
  --name podpingd-post \
  --env-file .env \
  --cap-add SYS_RESOURCE \
  podpingd-post

Monitoring

The application logs can be monitored in several ways:

Live Container Logs

docker logs -f podpingd-post

Individual Component Logs

View specific log files inside the container:

# Podpingd logs (Rust blockchain monitor)
docker exec podpingd-post cat /var/log/supervisor/podpingd.log
docker exec podpingd-post cat /var/log/supervisor/podpingd-err.log

# Node.js poster logs
docker exec podpingd-post cat /var/log/supervisor/poster.log
docker exec podpingd-post cat /var/log/supervisor/poster-err.log

# Supervisor logs
docker exec podpingd-post cat /var/log/supervisor/supervisord.log

Follow Logs in Real-time

To watch logs as they update:

# Follow podpingd logs
docker exec podpingd-post tail -f /var/log/supervisor/podpingd.log

# Follow poster logs
docker exec podpingd-post tail -f /var/log/supervisor/poster.log

Error Handling

The watcher automatically restarts podpingd when:

  • No new files are detected for FILE_AGE_TIMEOUT_SEC seconds
  • MAX_CONSECUTIVE_FAILURES HTTP requests fail in a row

When restarting, it sets podpingd's start_datetime to RESTART_MINUTES in the past to catch up on missed podpings.

Development

The project uses:

  • Node.js for the file watcher and HTTP requests
  • Rust for podpingd (the blockchain monitor)
  • Supervisor for process management

To modify the Node.js watcher, edit app.js. For podpingd configuration, modify the TOML file specified in CONFIG_FILE.

About

Send POST requests to an endpoint on podping updates.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Rust 84.4%
  • JavaScript 12.2%
  • Dockerfile 3.4%