Hide Ugly Windows Terminal Window and allow for quit signal remotely
continuous-integration/drone/push Build is failing Details

This commit is contained in:
Martyn 2020-09-26 12:56:08 +02:00
parent 9948a9fc26
commit f431336f8d
2 changed files with 25 additions and 1 deletions

View File

@ -13,7 +13,7 @@ steps:
- cd dlserver
- go mod download
- go build .
- CGO_ENABLED=0 GOOS=windows go build -a -installsuffix cgo -o dlserver.exe .
- CGO_ENABLED=0 GOOS=windows -ldflags -H=windowsgui go build -a -installsuffix cgo -o dlserver.exe .
- name: get_win_ffmpeg
image: busybox

View File

@ -191,6 +191,28 @@ func FetchHandler(w http.ResponseWriter, r *http.Request) {
fmt.Fprint(w, "OK\n")
}
func PidHandler(w http.ResponseWriter, r *http.Request) {
//vars := mux.Vars(r)
w.WriteHeader(http.StatusOK)
if lastFilename != "" {
os.Remove(lastFilename)
}
fmt.Fprintf(w, "%d\n", os.Getpid())
}
func QuitHandler(w http.ResponseWriter, r *http.Request) {
//vars := mux.Vars(r)
w.WriteHeader(http.StatusOK)
if lastFilename != "" {
os.Remove(lastFilename)
}
fmt.Fprint(w, "BYE!\n")
go func() {
time.Sleep(10 * time.Second)
os.Exit(0)
}()
}
func StatusHandler(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-type", "application/json")
w.WriteHeader(http.StatusOK)
@ -213,6 +235,8 @@ func main() {
r.SkipClean(true)
r.Path("/get").Queries("url", "{.*}").HandlerFunc(FetchHandler)
r.HandleFunc("/status/", StatusHandler)
r.HandleFunc("/pid/", PidHandler)
r.HandleFunc("/quit/", QuitHandler)
r.HandleFunc("/", HomeHandler)
http.Handle("/", r)
c = make(chan float64, 999)