rabbit-worker/main.go

39 lines
883 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package main
import (
"fmt"
"log"
"net/http"
"os"
)
// Минимальный воркер для проверки, что nubes_http умеет запускать контейнеры.
// Никакой логики с Rabbit или Postgres нет — только HTTP health endpoint.
func getenv(key, def string) string {
val := os.Getenv(key)
if val == "" {
return def
}
return val
}
func main() {
port := getenv("PORT", "8080")
http.HandleFunc("/healthz", func(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(http.StatusOK)
_, _ = w.Write([]byte("ok"))
})
http.HandleFunc("/", func(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(http.StatusOK)
_, _ = w.Write([]byte("rabbit-worker ready"))
})
log.Printf("listening on :%s", port)
if err := http.ListenAndServe(fmt.Sprintf(":%s", port), nil); err != nil {
log.Fatal(err)
}
}