| OLD | NEW |
| 1 /* | 1 /* |
| 2 Common initialization for worker scripts. | 2 Common initialization for worker scripts. |
| 3 */ | 3 */ |
| 4 | 4 |
| 5 package worker_common | 5 package worker_common |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "flag" | 8 "flag" |
| 9 "os" |
| 10 |
| 11 "github.com/skia-dev/glog" |
| 9 | 12 |
| 10 "go.skia.org/infra/ct/go/util" | 13 "go.skia.org/infra/ct/go/util" |
| 11 "go.skia.org/infra/go/common" | 14 "go.skia.org/infra/go/common" |
| 15 "go.skia.org/infra/go/exec" |
| 12 ) | 16 ) |
| 13 | 17 |
| 14 var ( | 18 var ( |
| 15 Local = flag.Bool("local", false, "Running locally if true. As opposed t
o in production.") | 19 Local = flag.Bool("local", false, "Running locally if true. As opposed t
o in production.") |
| 16 ) | 20 ) |
| 17 | 21 |
| 18 func Init() { | 22 func Init() { |
| 19 common.Init() | 23 common.Init() |
| 20 if *Local { | 24 if *Local { |
| 21 util.SetVarsForLocal() | 25 util.SetVarsForLocal() |
| 26 } else { |
| 27 // Add depot_tools to the PATH. |
| 28 os.Setenv("PATH", os.Getenv("PATH")+":"+util.DepotToolsDir) |
| 29 // Bring up Xvfb on workers (for GCE instances). |
| 30 if _, _, err := exec.RunIndefinitely(&exec.Command{ |
| 31 Name: "sudo", |
| 32 Args: []string{"Xvfb", ":0", "-screen", "0", "128
0x1024x24"}, |
| 33 Env: []string{}, |
| 34 InheritPath: true, |
| 35 Timeout: util.XVFB_TIMEOUT, |
| 36 LogStdout: true, |
| 37 Stdout: nil, |
| 38 LogStderr: true, |
| 39 Stderr: nil, |
| 40 }); err != nil { |
| 41 // CT's baremetal machines will already have an active d
isplay 0. |
| 42 glog.Infof("Could not run Xvfb on Display 0: %s", err) |
| 43 } |
| 22 } | 44 } |
| 23 } | 45 } |
| OLD | NEW |