Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions provision-probe/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
config.yaml
54 changes: 54 additions & 0 deletions provision-probe/cmd/provision-probe/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package main

import (
"context"
"flag"
"fmt"
"os"
"os/signal"
"syscall"

"github.com/rs/zerolog/log"
"github.com/threefoldtech/provision-probe/pkg/app"
"github.com/threefoldtech/provision-probe/pkg/config"
"github.com/threefoldtech/provision-probe/pkg/logger"
)

func main() {
configPath := flag.String("config", "configs/config.yaml", "path to config file")
flag.Parse()

cfg, err := config.Load(*configPath)
if err != nil {
fmt.Fprintf(os.Stderr, "Failed to load config: %v\n", err)
os.Exit(1)
}

logger.Init(cfg.LogLevel)

application, err := app.New(cfg)
if err != nil {
log.Fatal().Err(err).Msg("Failed to initialize app")
}
defer application.Close()

ctx, cancel := context.WithCancel(context.Background())
defer cancel()

sigChan := make(chan os.Signal, 1)
signal.Notify(sigChan, os.Interrupt, syscall.SIGTERM)

go func() {
<-sigChan
log.Info().Msg("Shutdown signal received, finishing current work...")
cancel()

<-sigChan
log.Warn().Msg("Second shutdown signal received, forcing exit")
os.Exit(1)
}()

if err := application.Run(ctx); err != nil {
log.Fatal().Err(err).Msg("Service failed")
}
}
35 changes: 35 additions & 0 deletions provision-probe/configs/config.example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
api:
host: "0.0.0.0" # host for the API server
port: 8080 # port for the API server

timescaledb:
url: "postgresql://postgres:postgres@localhost:5432/provision_probe" # url for the timescaledb database


probe:
interval: "6h" # interval for the deployment cycle
concurrency_limit: 10 # concurrency limit for the deployment cycle
timeout: "10m" # timeout for the deployment cycle
workload_size: "light" # light, medium, heavy
shutdown_timeout: "30s" # timeout for graceful shutdown
retry:
max_retries: 3 # maximum number of retries for transient failures
initial_backoff: "1s" # initial backoff duration between retries
max_backoff: "30s" # maximum backoff duration
multiplier: 2.0 # exponential backoff multiplier

scoring:
window: "90d" # default window for the scoring (overwritten by the window query parameter)
min_attempts: 1 # default minimum attempts for the scoring (overwritten by the min_attempts query parameter)

grid:
network: "dev" # dev, qa, test, main
mnemonic: "" # mnemonic for the grid

nodes:
status: "up" # up, healthy
farms: [] # farm IDs to include (empty means all farms)
nodes: [] # node IDs to include (empty means all nodes)
exclude: [] # node IDs to exclude

log_level: "info"
30 changes: 30 additions & 0 deletions provision-probe/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
services:
timescaledb:
image: timescale/timescaledb:latest-pg16
container_name: provision-probe-db
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: provision_probe
ports:
- "${PG_PORT:-5432}:5432"
volumes:
- timescaledb-data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 10s
timeout: 5s
retries: 5

pgweb:
image: sosedoff/pgweb:latest
container_name: provision-probe-pgweb
ports:
- "${VIEW_PORT:-8081}:8081"
environment:
- PGWEB_DATABASE_URL=postgres://postgres:postgres@timescaledb:5432/provision_probe?sslmode=disable
depends_on:
- timescaledb

volumes:
timescaledb-data:
Loading
Loading