From 6708aeb531022efda8959ee9b907caaeeddf32b6 Mon Sep 17 00:00:00 2001 From: nxshock Date: Sun, 27 Mar 2022 13:12:36 +0500 Subject: [PATCH] Log host which sends job requests --- httpserver.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/httpserver.go b/httpserver.go index 69dea76..04d3f9b 100644 --- a/httpserver.go +++ b/httpserver.go @@ -3,6 +3,7 @@ package main import ( "bytes" "fmt" + "net" "net/http" "os" "time" @@ -53,7 +54,11 @@ func handleForceStart(w http.ResponseWriter, r *http.Request) { for _, jobEntry := range jobEntries { job := jobEntry.Job.(*Job) if job.FileName == jobName { - log.WithField("job", "http_server").Printf("forced start %s", job.FileName) + host, _, err := net.SplitHostPort(r.RemoteAddr) + if err != nil { + host = r.RemoteAddr + } + log.WithField("job", "http_server").Printf("forced start %s from %s", job.FileName, host) go job.Run() time.Sleep(time.Second / 4) // wait some time for job start http.Redirect(w, r, "/", http.StatusTemporaryRedirect)