Overview
The guard command starts the Watchdog monitoring service. It initializes connections to the database and Redis, then begins monitoring all configured URLs at their specified frequencies.
Usage
Aliases
Description
When you run the guard command, Watchdog:
- Loads environment variables from
.env
- Connects to PostgreSQL database
- Connects to Redis for caching and job queuing
- Initializes the orchestrator and supervisor
- Sets up monitoring intervals for all frequency tiers
- Starts monitoring all configured URLs
The service runs continuously until stopped (Ctrl+C).
Arguments
This command takes no arguments.
Flags
This command has no flags.
Monitoring frequencies
The guard command automatically sets up monitoring for the following frequency intervals:
- 10 seconds
- 30 seconds
- 1 minute
- 5 minutes
- 30 minutes
- 1 hour
- 12 hours
- 24 hours
URLs are checked according to their configured frequency.
Examples
Start the monitoring service
Expected output:
Connected to PostgreSQL database!
Watchdog is running
Using the short alias
Prerequisites
Before running the guard command, ensure:
-
You have a valid
.env file with required configuration:
DB_USER, DB_PASSWORD, DB_HOST, DB_PORT, DB_DATABASE
REDIS_HOST, REDIS_DB
- Email configuration for alerts
-
PostgreSQL is running and accessible
-
Redis is running and accessible
-
You have at least one URL configured (use the
add command)
Error handling
If the database or Redis connection fails, the guard command will panic and exit. Ensure both services are running before starting Watchdog.
Common errors
Database connection failed:
pgxpool connection failed: connection refused
Solution: Verify PostgreSQL is running and credentials in .env are correct.
Redis connection failed:
Solution: Verify Redis is running and REDIS_HOST in .env is correct.
Technical details
- Connection pool size for Redis: 10
- Minimum idle connections: 5
- Maximum retries: 3
- Read timeout: 30 seconds
- Write timeout: 30 seconds
- Dial timeout: 10 seconds
See also