6
6
"fmt"
7
7
"io/ioutil"
8
8
"net/http"
9
+ "os"
9
10
"os/exec"
10
11
"path"
11
12
"path/filepath"
@@ -44,7 +45,7 @@ type ResHealthCheck struct {
44
45
45
46
// HealthCheckHandler handles calling the default health-check scripts and
46
47
// returning the json-formatted results of each script.
47
- func HealthCheckHandler (w http.ResponseWriter , r * http.Request , srcpath string , ia string ) {
48
+ func HealthCheckHandler (w http.ResponseWriter , r * http.Request , scionRoot string , srcpath string , ia string ) {
48
49
hcResFp := path .Join (srcpath , resFileHealthCheck )
49
50
// read specified tests from json definition
50
51
fp := path .Join (srcpath , defFileHealthCheck )
@@ -55,6 +56,27 @@ func HealthCheckHandler(w http.ResponseWriter, r *http.Request, srcpath string,
55
56
}
56
57
log .Debug ("HealthCheckHandler" , "resFileHealthCheck" , string (raw ))
57
58
59
+ err = os .Setenv ("SCION_ROOT" , scionRoot + "/" )
60
+ if CheckError (err ) {
61
+ fmt .Fprintf (w , `{ "err": "` + err .Error ()+ `" }` )
62
+ return
63
+ }
64
+ err = os .Setenv ("SCION_BIN" , scionRoot + "/bin/" )
65
+ if CheckError (err ) {
66
+ fmt .Fprintf (w , `{ "err": "` + err .Error ()+ `" }` )
67
+ return
68
+ }
69
+ err = os .Setenv ("SCION_GEN" , scionRoot + "/gen/" )
70
+ if CheckError (err ) {
71
+ fmt .Fprintf (w , `{ "err": "` + err .Error ()+ `" }` )
72
+ return
73
+ }
74
+ err = os .Setenv ("SCION_LOGS" , scionRoot + "/logs/" )
75
+ if CheckError (err ) {
76
+ fmt .Fprintf (w , `{ "err": "` + err .Error ()+ `" }` )
77
+ return
78
+ }
79
+
58
80
var tests DefTests
59
81
err = json .Unmarshal ([]byte (raw ), & tests )
60
82
if CheckError (err ) {
0 commit comments