Skip to content

Commit a6ee823

Browse files
committed
Add healthcheck endpoint
1 parent b96fba0 commit a6ee823

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/healthcheck.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"log"
6+
"net/http"
7+
)
8+
9+
func handler(w http.ResponseWriter, r *http.Request) {
10+
fmt.Fprintf(w, "compose-updater online")
11+
}
12+
13+
func Healthcheck() {
14+
http.HandleFunc("/", handler)
15+
log.Println("Starting healthcheck server at port 8080...")
16+
if err := http.ListenAndServe(":8080", nil); err != nil {
17+
log.Println(err)
18+
}
19+
}

src/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ func printHeader() {
3030

3131
func mainLoop() {
3232
updater := &Updater{}
33+
go Healthcheck();
3334
for {
3435
updater.PerformComposeUpdates()
3536
if GlobalSettings.Once {

0 commit comments

Comments
 (0)