-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add wrapper * fix step name * check files * no cgo * fix lint issues * fix missing dep * send http status * fix order * ignore error * switch target branch to main * update go * fix order
- Loading branch information
1 parent
62138d7
commit a3dedb4
Showing
6 changed files
with
69 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
"net/http" | ||
"os" | ||
"os/exec" | ||
) | ||
|
||
func main() { | ||
args := os.Args[1:] | ||
|
||
if len(args) < 2 { | ||
log.Fatal("missing arguments") | ||
} | ||
/* #nosec */ | ||
cmd := exec.Command(args[0], args[1:]...) | ||
cmd.Stderr = os.Stderr | ||
cmd.Stdout = os.Stdout | ||
if err := cmd.Start(); err != nil { | ||
log.Fatal(err) | ||
} | ||
server := &http.Server{Addr: ":8090", Handler: nil} | ||
http.HandleFunc("/kill", func(w http.ResponseWriter, r *http.Request) { | ||
err := cmd.Process.Kill() | ||
if err != nil { | ||
fmt.Println("error killing process", err) | ||
} | ||
_, _ = w.Write([]byte(string("OK"))) | ||
w.WriteHeader(http.StatusAccepted) | ||
err = server.Shutdown(r.Context()) | ||
if err != nil { | ||
fmt.Println("error shuting down", err) | ||
} | ||
}) | ||
err := server.ListenAndServe() | ||
_ = cmd.Process.Kill() | ||
if err != nil { | ||
|
||
log.Fatal(err) | ||
} | ||
} |