From f00cbda230c0dc61eac94602ce19c4d1302e3e37 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 22 Feb 2026 23:28:21 +0000 Subject: [PATCH 1/4] Build static binary with CGO_ENABLED=0 to fix glibc version mismatch The server's glibc is older than what the GitHub Actions runner (Ubuntu 24.04) links against. The binary was requiring GLIBC_2.32 and GLIBC_2.34 but the server only has 2.31 or earlier. Setting CGO_ENABLED=0 produces a fully static binary with no glibc dependency, which runs on any Linux regardless of libc version. https://claude.ai/code/session_01SvqeKxC2hJbDnDAViSJSDk --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 2d8d5c2..333a44a 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -44,7 +44,7 @@ jobs: run: go mod download - name: Build Linux binary - run: GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o moon . + run: CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o moon . - name: Copy files to server uses: appleboy/scp-action@v0.1.7 From 4b6ab4967697475846d0d63c11cfd03cbef8cdd0 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 21 Feb 2026 01:26:27 +0000 Subject: [PATCH 2/4] Update app to handle riseset module changes The riseset module (v1.0.1-0.20260220080739-24891d86367a) added two new boolean fields to RiseSet: AlwaysAbove and AlwaysBelow, which distinguish "object never sets" (midnight sun) from "object never rises" (polar night). Previously both cases returned "-" for Rise and Set with no way to tell them apart. Changes: - go.mod/go.sum: upgrade to new riseset pseudo-version with the new fields - moon.go: use named constants riseset.Moon and riseset.Sun instead of magic numbers 1 and 2; new JSON fields are included automatically - calendar.html: render "Always above" / "Always below" in the table instead of showing "-" for polar day/night conditions - static/script.js: handle AlwaysAbove and AlwaysBelow in the /gettimes JSON response, displaying a descriptive message in the Rise/Set fields https://claude.ai/code/session_01T2dm9m2XwVaWyvAx6CDfhM --- calendar.html | 8 ++++---- go.mod | 4 ++-- go.sum | 2 ++ moon.go | 6 +++--- static/script.js | 14 +++++++++++--- 5 files changed, 22 insertions(+), 12 deletions(-) diff --git a/calendar.html b/calendar.html index 99e26e4..162cae7 100644 --- a/calendar.html +++ b/calendar.html @@ -42,10 +42,10 @@

📅 Moon Rise and Set Calendar

{{ range .Rows }} {{.Date}} - {{.Moon.Rise}} - {{.Moon.Set}} - {{.Sun.Rise}} - {{.Sun.Set}} + {{if .Moon.AlwaysAbove}}Always above{{else if .Moon.AlwaysBelow}}Always below{{else}}{{.Moon.Rise}}{{end}} + {{if .Moon.AlwaysAbove}}Always above{{else if .Moon.AlwaysBelow}}Always below{{else}}{{.Moon.Set}}{{end}} + {{if .Sun.AlwaysAbove}}Always above{{else if .Sun.AlwaysBelow}}Always below{{else}}{{.Sun.Rise}}{{end}} + {{if .Sun.AlwaysAbove}}Always above{{else if .Sun.AlwaysBelow}}Always below{{else}}{{.Sun.Set}}{{end}} {{ end }} diff --git a/go.mod b/go.mod index 45d1d14..10b958c 100644 --- a/go.mod +++ b/go.mod @@ -1,5 +1,5 @@ module moon -go 1.21 +go 1.24.7 -require github.com/exploded/riseset v1.0.0 +require github.com/exploded/riseset v1.0.1-0.20260220080739-24891d86367a diff --git a/go.sum b/go.sum index bfad37f..b870990 100644 --- a/go.sum +++ b/go.sum @@ -1,2 +1,4 @@ github.com/exploded/riseset v1.0.0 h1:qdXzKgiEieF8hJSvmONRYcX4QalBMkFnUf1xuW6YIxM= github.com/exploded/riseset v1.0.0/go.mod h1:VjRq5iJAosiDcmN6cIemg4Koh/g/MirLmI9djQoiuYs= +github.com/exploded/riseset v1.0.1-0.20260220080739-24891d86367a h1:9zXloV9qOl/7d9DUghsbK2l0w1xM0ebmEjMWk8KCS4Y= +github.com/exploded/riseset v1.0.1-0.20260220080739-24891d86367a/go.mod h1:iSOrtnvmvgDPXhfjH+isdiLP0aTLSlIExl2z6Tulizg= diff --git a/moon.go b/moon.go index 8e30c58..513d6aa 100644 --- a/moon.go +++ b/moon.go @@ -214,8 +214,8 @@ func calendar(w http.ResponseWriter, r *http.Request) { for i := 0; i < 10; i++ { newdate = newdate.AddDate(0, 0, 1) arow.Date = newdate.Format("02-01-2006") - arow.Moon = riseset.Riseset(1, newdate, Lon, Lat, Zon) - arow.Sun = riseset.Riseset(2, newdate, Lon, Lat, Zon) + arow.Moon = riseset.Riseset(riseset.Moon, newdate, Lon, Lat, Zon) + arow.Sun = riseset.Riseset(riseset.Sun, newdate, Lon, Lat, Zon) Passme.Rows = append(Passme.Rows, arow) } @@ -299,7 +299,7 @@ func gettimes(w http.ResponseWriter, r *http.Request) { var newdate time.Time zondur = time.Hour * time.Duration(zon) newdate = time.Now().Add(zondur) - mydata = riseset.Riseset(1, newdate, lon, lat, zon) + mydata = riseset.Riseset(riseset.Moon, newdate, lon, lat, zon) } json.NewEncoder(w).Encode(mydata) } diff --git a/static/script.js b/static/script.js index e8fb78c..bbf7ca3 100644 --- a/static/script.js +++ b/static/script.js @@ -293,12 +293,20 @@ const getTimes = function () { $.getJSON(`gettimes?lon=${mylon}&lat=${mylat}&zon=${zon}`) .done((json) => { - if (json.Rise && json.Set) { + if (json.Rise === "error" || json.Set === "error") { + showErrorMessage('Unable to calculate moon times for this location.'); + } else if (json.AlwaysAbove) { + updateInputField("Rise", "Always above horizon"); + updateInputField("Set", "Always above horizon"); + clearErrorMessage(); + } else if (json.AlwaysBelow) { + updateInputField("Rise", "Always below horizon"); + updateInputField("Set", "Always below horizon"); + clearErrorMessage(); + } else if (json.Rise && json.Set) { updateInputField("Rise", json.Rise); updateInputField("Set", json.Set); clearErrorMessage(); - } else if (json.Rise === "error" || json.Set === "error") { - showErrorMessage('Unable to calculate moon times for this location.'); } }) .fail((jqXHR, textStatus, errorThrown) => { From 8ab626033c4415ec308fc7e9012d47b701502b19 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 23 Feb 2026 00:24:35 +0000 Subject: [PATCH 3/4] Read PORT from environment variable instead of hardcoding 8181 The app previously hardcoded :8181 which caused a startup crash when that port was already in use on the server. The port is now read from the PORT env var (falling back to 8181 if unset), so it can be controlled via /var/www/moon/.env alongside GOOGLE_MAPS_API_KEY. Also cherry-picked the riseset module update (AlwaysAbove/AlwaysBelow named constants) from the parallel branch that was never merged. https://claude.ai/code/session_01SvqeKxC2hJbDnDAViSJSDk --- moon.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/moon.go b/moon.go index 513d6aa..9132977 100644 --- a/moon.go +++ b/moon.go @@ -114,12 +114,18 @@ func makeHTTPServer() *http.Server { func main() { var flgProduction bool - var httpPort string = ":8181" if os.Getenv("PROD") == "True" { flgProduction = true } else { flgProduction = false } + + httpPort := os.Getenv("PORT") + if httpPort == "" { + httpPort = "8181" + } + httpPort = ":" + httpPort + log.Printf("Production: %v", flgProduction) log.Printf("HTTP Port: %s", httpPort) From bacebaf0054fdebebedad6fdfbe5b2ec7c68811d Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 23 Feb 2026 00:28:45 +0000 Subject: [PATCH 4/4] Fix default port to 8484 https://claude.ai/code/session_01SvqeKxC2hJbDnDAViSJSDk --- moon.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/moon.go b/moon.go index 9132977..ac7a1ba 100644 --- a/moon.go +++ b/moon.go @@ -122,7 +122,7 @@ func main() { httpPort := os.Getenv("PORT") if httpPort == "" { - httpPort = "8181" + httpPort = "8484" } httpPort = ":" + httpPort