initial
Build and Push Docker Image / build-and-push (push) Failing after 1m41s

This commit is contained in:
kaedwen committed 2026-07-02 20:09:44 +02:00
commit ea141eb012
73 files changed
+10609

No files matched your search

+65
View File
@@ -0,0 +1,65 @@
package main
import (
"context"
"log/slog"
"os"
"os/signal"
"syscall"
"github.com/pheinrich/aitrade/pkg/app"
"github.com/pheinrich/aitrade/pkg/config"
)
func main() {
// Load configuration
cfg, err := config.LoadYAMLOrEnv()
if err != nil {
slog.Error("failed to load config", slog.Any("error", err))
os.Exit(1)
}
// Setup logger (sets up both slog and ibapi logging)
logger := cfg.SetupLogger()
logger.Info("starting AI trading application",
slog.String("strategy", cfg.Trading.Strategy),
slog.String("db_path", cfg.Database.Path),
)
// Create application
application, err := app.New(cfg, logger)
if err != nil {
logger.Error("failed to create application", slog.Any("error", err))
os.Exit(1)
}
defer application.Close()
// Setup signal handling
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
sigChan := make(chan os.Signal, 1)
signal.Notify(sigChan, syscall.SIGINT, syscall.SIGTERM)
// Run application
errChan := make(chan error, 1)
go func() {
errChan <- application.Run(ctx)
}()
// Wait for signal or error
select {
case sig := <-sigChan:
logger.Info("received signal", slog.String("signal", sig.String()))
cancel()
<-errChan // Wait for graceful shutdown
case err := <-errChan:
if err != nil {
logger.Error("application error", slog.Any("error", err))
os.Exit(1)
}
}
logger.Info("application stopped")
}
+45
View File
@@ -0,0 +1,45 @@
package main
import (
"fmt"
"net/http"
"os"
"time"
)
func main() {
// Get host and port from args or use defaults
host := "localhost"
port := "8080"
if len(os.Args) > 1 {
host = os.Args[1]
}
if len(os.Args) > 2 {
port = os.Args[2]
}
url := fmt.Sprintf("http://%s:%s/health", host, port)
// Create HTTP client with timeout
client := &http.Client{
Timeout: 3 * time.Second,
}
// Make request
resp, err := client.Get(url)
if err != nil {
fmt.Fprintf(os.Stderr, "Health check failed: %v\n", err)
os.Exit(1)
}
defer resp.Body.Close()
// Check status code
if resp.StatusCode != http.StatusOK {
fmt.Fprintf(os.Stderr, "Health check failed: HTTP %d\n", resp.StatusCode)
os.Exit(1)
}
// Success
os.Exit(0)
}