1
0

」 feat: Changed folder structure to comply with the dumb subject

This commit is contained in:
2025-01-12 15:17:52 +01:00
parent 45ef1f3ddf
commit 9f8cf6b3ea
17 changed files with 40 additions and 37 deletions

View File

@ -0,0 +1,38 @@
package main
import (
"os"
"fmt"
"os/exec"
"git.keyzox.me/42_adjoly/inception/internal/env"
)
func checkMariaDB(user, password, host, port string) bool {
// Create the command to run mariadb client
cmd := exec.Command("mariadb", "-u"+user, "-p"+password, "-h"+host, "-P"+port, "-e", "SELECT 1;")
// Run the command
err := cmd.Run()
if err != nil {
fmt.Printf("Health check failed: %v\n", err)
return false
}
fmt.Println("MariaDB is healthy")
return true
}
func main() {
// Configuration
user := env.EscapeEnv(env.FileEnv("MYSQL_USER", "mariadb"))
password := env.EscapeEnv(env.FileEnv("MYSQL_PASSWORD", "default"))
host := "127.0.0.1"
port := "3306"
if checkMariaDB(user, password, host, port) {
os.Exit(0) // Success
}
fmt.Println("MariaDB health check failed")
os.Exit(1) // Failure
}