Potentieller Persistenz-Fix
All checks were successful
release-tag / release-image (push) Successful in 2m10s
All checks were successful
release-tag / release-image (push) Successful in 2m10s
This commit is contained in:
@@ -6,8 +6,10 @@ import (
|
|||||||
"html/template"
|
"html/template"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
"os/signal"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.send.nrw/sendnrw/b1tsblog/internal/article"
|
"git.send.nrw/sendnrw/b1tsblog/internal/article"
|
||||||
@@ -93,6 +95,18 @@ var (
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
||||||
|
// Signal-Kanal einrichten
|
||||||
|
stop := make(chan os.Signal, 1)
|
||||||
|
signal.Notify(stop, syscall.SIGINT, syscall.SIGTERM)
|
||||||
|
|
||||||
|
// Goroutine, die auf Signale wartet
|
||||||
|
go func() {
|
||||||
|
<-stop
|
||||||
|
fmt.Println("Stop Sign...")
|
||||||
|
prepareExit()
|
||||||
|
os.Exit(0)
|
||||||
|
}()
|
||||||
|
|
||||||
// --- Verzeichnisse konfigurierbar machen -------------------------
|
// --- Verzeichnisse konfigurierbar machen -------------------------
|
||||||
contentDir := getenv("BLOG_CONTENT_DIR", "/content")
|
contentDir := getenv("BLOG_CONTENT_DIR", "/content")
|
||||||
staticDir := getenv("BLOG_STATIC_DIR", "/app/internal/web/static")
|
staticDir := getenv("BLOG_STATIC_DIR", "/app/internal/web/static")
|
||||||
@@ -196,11 +210,21 @@ func main() {
|
|||||||
cacheControl(http.StripPrefix("/static/",
|
cacheControl(http.StripPrefix("/static/",
|
||||||
http.FileServer(http.Dir(staticDir)))))
|
http.FileServer(http.Dir(staticDir)))))
|
||||||
|
|
||||||
http.ListenAndServe(":8080", mux)
|
StopServer(http.ListenAndServe(":8080", mux))
|
||||||
|
|
||||||
if err := SaveTickCatalog(ticksDir + "/ticks.json"); err != nil {
|
}
|
||||||
|
|
||||||
|
func prepareExit() {
|
||||||
|
fmt.Println("~", "Running exit tasks...")
|
||||||
|
if err := SaveTickCatalog(getenv("BLOG_TICKS_DIR", "/ticks") + "/ticks.json"); err != nil {
|
||||||
fmt.Println("Fehler beim Speichern:", err)
|
fmt.Println("Fehler beim Speichern:", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println("Geladener Katalog:", TickCatalog)
|
fmt.Println("Geladener Katalog:", TickCatalog)
|
||||||
|
fmt.Println("~", "Exit completed.")
|
||||||
|
}
|
||||||
|
|
||||||
|
func StopServer(e error) {
|
||||||
|
fmt.Println("~", "Stopping server...")
|
||||||
|
prepareExit()
|
||||||
|
fmt.Println("~", "Server stopped!")
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user