File tree 2 files changed +21
-3
lines changed
2 files changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -25,22 +25,22 @@ func killBrowserHandler(c *gin.Context) {
25
25
command , err := findBrowser (data .Process )
26
26
27
27
if err != nil {
28
- c .JSON (http .StatusInternalServerError , err .Error ())
28
+ c .JSON (http .StatusInternalServerError , gin. H { "when" : "find" , " err" : err .Error ()} )
29
29
return
30
30
}
31
31
32
32
if data .Action == "kill" || data .Action == "restart" {
33
33
_ , err := killBrowser (data .Process )
34
34
if err != nil {
35
- c .JSON (http .StatusInternalServerError , err .Error ())
35
+ c .JSON (http .StatusInternalServerError , gin. H { "when" : "kill" , " err" : err .Error ()} )
36
36
return
37
37
}
38
38
}
39
39
40
40
if data .Action == "restart" {
41
41
_ , err := startBrowser (command , data .URL )
42
42
if err != nil {
43
- c .JSON (http .StatusInternalServerError , err .Error ())
43
+ c .JSON (http .StatusInternalServerError , gin. H { "when" : "start" , " err" : err .Error ()} )
44
44
return
45
45
}
46
46
}
Original file line number Diff line number Diff line change 1
1
package main
2
2
3
3
import (
4
+ "log"
4
5
"os/exec"
5
6
"strings"
6
7
)
@@ -10,16 +11,33 @@ func findBrowser(process string) ([]byte, error) {
10
11
grep := exec .Command ("grep" , process )
11
12
head := exec .Command ("head" , "-n" , "1" )
12
13
14
+ log .Println ("ps command:" )
15
+ log .Printf ("%+v" , ps )
16
+
17
+ log .Println ("grep command:" )
18
+ log .Printf ("%+v" , grep )
19
+
20
+ log .Println ("head command:" )
21
+ log .Printf ("%+v" , head )
22
+
13
23
return pipe_commands (ps , grep , head )
14
24
}
15
25
16
26
func killBrowser (process string ) ([]byte , error ) {
17
27
cmd := exec .Command ("pkill" , "-9" , process )
28
+
29
+ log .Println ("kill command:" )
30
+ log .Printf ("%+v" , cmd )
31
+
18
32
return cmd .Output ()
19
33
}
20
34
21
35
func startBrowser (command []byte , url string ) ([]byte , error ) {
22
36
parts := strings .Split (string (command ), " " )
23
37
cmd := exec .Command (parts [0 ], url )
38
+
39
+ log .Println ("start command:" )
40
+ log .Printf ("%+v" , cmd )
41
+
24
42
return cmd .Output ()
25
43
}
You can’t perform that action at this time.
0 commit comments