39 lines
883 B
Go
39 lines
883 B
Go
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)
|
||
}
|
||
}
|