diff --git a/build/ci/drone.yml b/build/ci/drone.yml index 35dd44d..a160555 100644 --- a/build/ci/drone.yml +++ b/build/ci/drone.yml @@ -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 diff --git a/dlserver/main.go b/dlserver/main.go index 1575f36..5ea7686 100644 --- a/dlserver/main.go +++ b/dlserver/main.go @@ -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)