server: implement scylladb
This commit is contained in:
+27
-1
@@ -2,12 +2,38 @@ package main
|
||||
|
||||
import (
|
||||
"log/slog"
|
||||
"os"
|
||||
|
||||
"git.dubyatp.xyz/dubyatp/scannerbot/server/api"
|
||||
"github.com/joho/godotenv"
|
||||
)
|
||||
|
||||
var REQUIRED_ENVS = [...]string{
|
||||
"SCYLLA_CLUSTER", "SCYLLA_KEYSPACE",
|
||||
}
|
||||
|
||||
func checkEnvVars(keys []string) (bool, []string) {
|
||||
var missing []string
|
||||
for _, key := range keys {
|
||||
if _, ok := os.LookupEnv(key); !ok {
|
||||
missing = append(missing, key)
|
||||
}
|
||||
}
|
||||
return len(missing) == 0, missing
|
||||
}
|
||||
|
||||
func main() {
|
||||
//println("hello world")
|
||||
|
||||
err := godotenv.Load()
|
||||
if err != nil {
|
||||
slog.Debug("No .env file loaded, will try OS environment variables")
|
||||
}
|
||||
|
||||
exists, missingVars := checkEnvVars(REQUIRED_ENVS[:])
|
||||
if !exists {
|
||||
slog.Error("Missing environment variables", "missing", missingVars)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
slog.Info("Starting the API server...")
|
||||
api.Start()
|
||||
|
||||
Reference in New Issue
Block a user