Vary title for executable

This commit is contained in:
Josh Deprez 2024-04-26 09:38:00 +10:00
parent 2d8897768b
commit 15621ec7e0
Signed by: josh
SSH key fingerprint: SHA256:zZji7w1Ilh2RuUpbQcqkLPrqmRwpiCSycbF2EfKm6Kw
3 changed files with 14 additions and 4 deletions

View file

@ -14,6 +14,7 @@ import (
"net/http"
"os"
"os/user"
"path/filepath"
"runtime"
"strings"
"sync"
@ -38,8 +39,14 @@ var (
}
return fmt.Sprintf("%s (uid=%s)", user.Username, user.Uid)
}()
exepath, _ = os.Executable()
startTime = time.Now()
exepath, exename = func() (string, string) {
exe, _ := os.Executable()
if exe == "" {
return "(unknown)", "(unknown)"
}
return exe, filepath.Base(exe)
}()
startTime = time.Now()
rootItem = &simpleItem{
baseItem: baseItem{
@ -63,6 +70,7 @@ type statusData struct {
Build string
Hostname string
Username string
ExeName string
ExePath string
PID int
Compiler string
@ -191,6 +199,7 @@ func Handle(w http.ResponseWriter, r *http.Request) {
Build: "TODO",
Hostname: hostname,
Username: username,
ExeName: exename,
ExePath: exepath,
PID: os.Getpid(),
Compiler: runtime.Compiler,

View file

@ -10,7 +10,7 @@
<!DOCTYPE html>
<html>
<head>
<title>Status</title>
<title>Status for {{.ExeName}}</title>
<style>
body {
font-family: sans-serif;
@ -62,7 +62,7 @@
</style>
</head>
<body>
<h1>Status</h1>
<h1>Status for {{.ExeName}}</h1>
<div class="summary">
{{.ExePath}}<br>
Started at {{.StartTime}} ({{.StartTimeAgo}} ago)<br>

View file

@ -47,6 +47,7 @@ func TestSmokeStatusTemplate(t *testing.T) {
Build: "1234",
Hostname: hostname,
Username: username,
ExeName: exename,
ExePath: exepath,
PID: os.Getpid(),
Compiler: runtime.Compiler,