mirror of
https://github.com/nxshock/gron.git
synced 2024-11-27 03:41:00 +05:00
Add menu with shutdown button
This commit is contained in:
parent
970ce3bdae
commit
5d77188c05
@ -4,6 +4,7 @@ import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
@ -11,6 +12,7 @@ import (
|
||||
|
||||
func httpServer(listenAddress string) {
|
||||
http.HandleFunc("/", handler)
|
||||
http.HandleFunc("/shutdown", handleShutdown)
|
||||
http.HandleFunc("/start", handleForceStart)
|
||||
log.WithField("job", "http_server").Fatal(http.ListenAndServe(listenAddress, nil))
|
||||
}
|
||||
@ -56,3 +58,14 @@ func handleForceStart(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
http.Error(w, fmt.Sprintf("there is no job with name %s", jobName), http.StatusBadRequest)
|
||||
}
|
||||
|
||||
func handleShutdown(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(http.StatusOK)
|
||||
w.Write([]byte("Application terminated.\n"))
|
||||
|
||||
go func() {
|
||||
time.Sleep(time.Second)
|
||||
log.WithField("job", "http_server").Infoln("Shutdown requested")
|
||||
os.Exit(0)
|
||||
}()
|
||||
}
|
||||
|
43
index.htm
43
index.htm
@ -65,7 +65,7 @@
|
||||
}
|
||||
|
||||
th {
|
||||
background-color: var(--base02);
|
||||
background-color: var(--base01);
|
||||
}
|
||||
|
||||
td,
|
||||
@ -74,7 +74,7 @@
|
||||
padding: 0.25em;
|
||||
}
|
||||
|
||||
button {
|
||||
table button {
|
||||
width: 100%;
|
||||
color: #fff;
|
||||
background-color: var(--base01);
|
||||
@ -99,11 +99,50 @@
|
||||
.runningbg {
|
||||
background-color: var(--base0B);
|
||||
}
|
||||
|
||||
.dropbtn {
|
||||
background-color: var(--base01);
|
||||
color: var(--base05);
|
||||
padding: 0.5em;
|
||||
cursor: pointer;
|
||||
border: 0;
|
||||
}
|
||||
|
||||
.dropdown {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
float: right;
|
||||
}
|
||||
|
||||
.dropdown-content {
|
||||
display: none;
|
||||
position: absolute;
|
||||
right: 0;
|
||||
background-color: var(--base01);
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.dropdown-content a {
|
||||
color: var(--base05);
|
||||
padding: 0.5em;
|
||||
text-decoration: none;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.dropdown:hover .dropdown-content {
|
||||
display: block;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<main>
|
||||
<div class="dropdown">
|
||||
<button class="dropbtn">☰ Menu</button>
|
||||
<div class="dropdown-content">
|
||||
<a href="/shutdown">Shutdown</a>
|
||||
</div>
|
||||
</div>
|
||||
<h1>Job list</h1>
|
||||
<table>
|
||||
<tr>
|
||||
|
Loading…
Reference in New Issue
Block a user