Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Axeos Regulator

A Go application for monitoring REST API endpoints on a schedule, making decisions based on response data, and providing a web interface for visualization and control.

Features

  • πŸ”„ Scheduled API Calls: Execute REST API requests on configurable cron schedules
  • πŸ“Š Web Dashboard: Real-time visualization of API call results and status
  • βš™οΈ Configurable Endpoints: YAML-based configuration for easy endpoint management
  • 🎯 Rule Engine: Define conditions and actions based on API responses
  • 🐳 Docker Support: Multi-platform Docker images (linux/amd64, linux/arm64)
  • πŸš€ CI/CD Ready: GitHub Actions workflow for automated testing and builds
  • πŸ’ͺ Cross-Platform: Runs on macOS, Linux (Ubuntu Server, etc.)

Quick Start

Prerequisites

  • Go 1.21+ (for local development)
  • Docker & Docker Compose (for containerized deployment)

Install Go (macOS)

# Using Homebrew
brew install go

# Verify installation
go version

Install Go (Ubuntu Server)

# Download and install
wget https://go.dev/dl/go1.21.0.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf go1.21.0.linux-amd64.tar.gz

# Add to PATH (add to ~/.profile or ~/.bashrc)
export PATH=$PATH:/usr/local/go/bin

# Verify installation
go version

Local Development

# Clone the repository
git clone <your-repo-url>
cd axeos-regulator

# Install dependencies
go mod download

# Run the application
go run main.go

# Or use Make
make run

The web interface will be available at http://localhost:8080

Docker Deployment

# Using Docker Compose (recommended)
docker-compose up -d

# Or build and run manually
docker build -t axeos-regulator .
docker run -p 8080:8080 -v $(pwd)/config.yaml:/root/config.yaml axeos-regulator

Configuration

Edit config.yaml to configure your API endpoints:

endpoints:
  - name: "My API Health Check"
    url: "https://api.example.com/health"
    method: "GET"
    schedule: "*/5 * * * *"  # Every 5 minutes
    headers:
      Authorization: "Bearer YOUR_TOKEN"
    rules:
      - name: "Check Status"
        condition: "status_code_not_200"
        action: "log_alert"

Schedule Format (Cron)

The schedule uses standard cron syntax:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ minute (0 - 59)
β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ hour (0 - 23)
β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ day of month (1 - 31)
β”‚ β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ month (1 - 12)
β”‚ β”‚ β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ day of week (0 - 6) (Sunday to Saturday)
β”‚ β”‚ β”‚ β”‚ β”‚
* * * * *

Examples:

  • */5 * * * * - Every 5 minutes
  • 0 * * * * - Every hour
  • 0 0 * * * - Daily at midnight
  • 0 9-17 * * 1-5 - Every hour 9am-5pm, Monday-Friday
  • */15 9-17 * * 1-5 - Every 15 minutes during business hours

Rule Conditions

Built-in conditions:

  • status_code_not_200 - HTTP status is not 200
  • status_code_error - HTTP status >= 400
  • has_error - Request encountered an error

Project Structure

axeos-regulator/
β”œβ”€β”€ main.go                 # Application entry point
β”œβ”€β”€ go.mod                  # Go module definition
β”œβ”€β”€ config.yaml             # Configuration file
β”œβ”€β”€ Dockerfile              # Docker image definition
β”œβ”€β”€ docker-compose.yml      # Docker Compose setup
β”œβ”€β”€ Makefile                # Build automation
β”œβ”€β”€ internal/
β”‚   β”œβ”€β”€ config/            # Configuration management
β”‚   β”‚   └── config.go
β”‚   β”œβ”€β”€ scheduler/         # API scheduler & executor
β”‚   β”‚   └── scheduler.go
β”‚   └── web/               # Web server & UI
β”‚       └── server.go
└── .github/
    └── workflows/
        └── ci.yml         # GitHub Actions CI/CD

API Endpoints

The web server exposes several REST endpoints:

  • GET / - Web dashboard
  • GET /api/results - JSON of all results
  • POST /api/execute/{name} - Execute endpoint immediately
  • GET /api/config - View current configuration
  • GET /health - Health check endpoint

Development

Available Make Commands

make help        # Show all available commands
make build       # Build the application
make run         # Run the application
make test        # Run tests
make clean       # Clean build artifacts
make docker      # Build Docker image
make docker-run  # Run with Docker Compose
make build-all   # Build for all platforms

Running Tests

# Run all tests
go test -v ./...

# Run tests with coverage
go test -v -race -coverprofile=coverage.txt ./...

# View coverage
go tool cover -html=coverage.txt

Building for Different Platforms

# Linux (amd64)
GOOS=linux GOARCH=amd64 go build -o axeos-regulator-linux-amd64

# Linux (arm64) - for Raspberry Pi, AWS Graviton, etc.
GOOS=linux GOARCH=arm64 go build -o axeos-regulator-linux-arm64

# macOS (Intel)
GOOS=darwin GOARCH=amd64 go build -o axeos-regulator-darwin-amd64

# macOS (Apple Silicon)
GOOS=darwin GOARCH=arm64 go build -o axeos-regulator-darwin-arm64

# Or use Make
make build-all

GitHub Actions

The project includes a CI/CD pipeline that:

  1. Tests: Runs on every push and PR
  2. Builds: Creates binaries for multiple platforms
  3. Docker: Builds multi-platform Docker images
  4. Release: Automatically publishes on GitHub releases

Setting up Docker Hub Publishing

To enable automatic Docker image publishing:

  1. Create Docker Hub account and repository
  2. Add GitHub repository secrets:
    • DOCKER_USERNAME: Your Docker Hub username
    • DOCKER_PASSWORD: Your Docker Hub token/password

Deployment Examples

Ubuntu Server

# Download the binary
wget https://github.com/yourusername/axeos-regulator/releases/latest/download/axeos-regulator-linux-amd64

# Make executable
chmod +x axeos-regulator-linux-amd64

# Create config
nano config.yaml

# Run
./axeos-regulator-linux-amd64 -config config.yaml -port 8080

Using systemd (Ubuntu)

Create /etc/systemd/system/axeos-regulator.service:

[Unit]
Description=Axeos Regulator API Monitor
After=network.target

[Service]
Type=simple
User=axeos
WorkingDirectory=/opt/axeos-regulator
ExecStart=/opt/axeos-regulator/axeos-regulator -config /opt/axeos-regulator/config.yaml
Restart=on-failure

[Install]
WantedBy=multi-user.target
sudo systemctl enable axeos-regulator
sudo systemctl start axeos-regulator
sudo systemctl status axeos-regulator

Command Line Options

./axeos-regulator -h

Options:
  -config string
        Path to configuration file (default "config.yaml")
  -port string
        Web server port (default "8080")

Coming from Java/Node.js?

Key differences in Go:

  • No classes: Go uses structs and interfaces instead
  • Explicit error handling: No try/catch, functions return errors
  • Goroutines: Lightweight threads using go func()
  • Channels: Built-in message passing between goroutines
  • No package manager like npm: Go modules are built-in (go.mod)
  • Static typing: All types are explicit
  • Compiled: Single binary, no runtime needed
  • Fast: Compiles and runs very quickly

License

MIT License - see LICENSE file for details

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

About

A Go developed app to regulate AxeOS crypto Miners for optimal performance

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages