Skip to content

Commit ec190c0

Browse files
committed
Rename healthcheck route
1 parent bbc7fb1 commit ec190c0

3 files changed

Lines changed: 5 additions & 15 deletions

File tree

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ A lightweight Go service that combines ping health checks with power management
44

55
## Features
66

7-
- **HTTP Health Endpoints**: `/ping` (monitored) and `/health` (healthcheck)
7+
- **HTTP Health Endpoints**: `/ping` (monitored) and `/healthcheck`
88
- **Activity Monitoring**: Tracks requests to `/ping` endpoint
99
- **Configurable Timeouts**: Environment-controlled inactivity periods
1010
- **GCP Integration**: Automatic instance suspension via GCP API service
@@ -24,14 +24,13 @@ docker run -p 8808:8808 -e INACTIVITY_TIMEOUT=90 lightswitch:latest
2424
| `PORT` | `8808` | HTTP server port |
2525
| `INACTIVITY_TIMEOUT` | `90` | Seconds of inactivity before shutdown |
2626
| `CHECK_INTERVAL` | `30` | Seconds between activity checks |
27-
| `LIBOPS_PROXY_URL` | - | GCP proxy URL for suspension |
2827
| `LIBOPS_KEEP_ONLINE` | - | Set to "yes" to disable auto-shutdown |
2928
| `LOG_LEVEL` | `INFO` | Logging level (DEBUG, INFO, WARN, ERROR) |
3029

3130
### Endpoints
3231

3332
- `GET /ping` - Returns "pong", activity is logged and monitored
34-
- `GET /health` - Returns "healthy", used for container healthchecks
33+
- `GET /healthcheck` - used for container healthchecks
3534

3635
## Integration
3736

@@ -43,7 +42,7 @@ This service is designed to work in tandem with [ppb (Proxy Power Button)](https
4342
- Receives incoming requests for dormant instances
4443
- Starts the GCE instance via GCP API
4544
- Proxies requests to the now-running backend
46-
45+
4746
2. **lightsout (Shutdown)**: Monitors activity and automatically shuts down instances during idle periods
4847
- Tracks activity via `/ping` endpoint calls
4948
- Monitors for configurable inactivity timeouts

main.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -363,11 +363,6 @@ func pingHandler(w http.ResponseWriter, r *http.Request) {
363363
func healthHandler(w http.ResponseWriter, r *http.Request) {
364364
w.Header().Set("Content-Type", "text/plain")
365365
w.WriteHeader(http.StatusOK)
366-
if _, err := w.Write([]byte("healthy")); err != nil {
367-
slog.Error("Failed to write health response", "error", err)
368-
http.Error(w, "Failed to write response", http.StatusInternalServerError)
369-
return
370-
}
371366
}
372367

373368
func main() {
@@ -384,7 +379,7 @@ func main() {
384379

385380
// Setup HTTP handlers
386381
http.HandleFunc("/ping", pingHandler)
387-
http.HandleFunc("/health", healthHandler)
382+
http.HandleFunc("/healthcheck", healthHandler)
388383

389384
// Setup HTTP server
390385
server := &http.Server{

main_test.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ func TestHealthEndpoint(t *testing.T) {
221221
cleanup := setupTestEnvironment()
222222
defer cleanup()
223223

224-
req := httptest.NewRequest("GET", "/health", nil)
224+
req := httptest.NewRequest("GET", "/healthcheck", nil)
225225
w := httptest.NewRecorder()
226226

227227
healthHandler(w, req)
@@ -230,10 +230,6 @@ func TestHealthEndpoint(t *testing.T) {
230230
t.Fatalf("Expected status 200, got %d", w.Code)
231231
}
232232

233-
if w.Body.String() != "healthy" {
234-
t.Fatalf("Expected 'healthy', got '%s'", w.Body.String())
235-
}
236-
237233
if w.Header().Get("Content-Type") != "text/plain" {
238234
t.Fatalf("Expected Content-Type 'text/plain', got '%s'", w.Header().Get("Content-Type"))
239235
}

0 commit comments

Comments
 (0)