mirror of
https://github.com/alvierahman90/gohookr.git
synced 2024-11-24 18:19:53 +00:00
Run tests and script in parralel to prevent timing out
This commit is contained in:
parent
081aaee9c7
commit
a3ded5a052
17
main.go
17
main.go
@ -75,6 +75,8 @@ func webhookHandler(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
// run test and script in parralel to prevent timing out
|
||||
go func(){
|
||||
// Run tests, immediately stop if one fails
|
||||
for _, test := range service.Tests {
|
||||
if _, err := test.Execute(payload); err != nil {
|
||||
@ -84,14 +86,15 @@ func webhookHandler(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if stdout, err := service.Script.Execute(payload); err != nil {
|
||||
writeResponse(w, 500, err.Error())
|
||||
return
|
||||
} else {
|
||||
writeResponse(w, 200, string(stdout))
|
||||
return
|
||||
stdout, err := service.Script.Execute(payload)
|
||||
fmt.Println(stdout)
|
||||
if err != nil {
|
||||
fmt.Println(err.Error())
|
||||
}
|
||||
}()
|
||||
|
||||
writeResponse(w, 200, "OK")
|
||||
return
|
||||
}
|
||||
|
||||
func writeResponse(w http.ResponseWriter, responseCode int, responseString string) {
|
||||
|
Loading…
Reference in New Issue
Block a user