OLD | NEW |
---|---|
1 // Utility that contains methods for both CT master and worker scripts. | 1 // Utility that contains methods for both CT master and worker scripts. |
2 package util | 2 package util |
3 | 3 |
4 import ( | 4 import ( |
5 "bufio" | 5 "bufio" |
6 "encoding/json" | |
6 "fmt" | 7 "fmt" |
7 "io" | 8 "io" |
8 "io/ioutil" | 9 "io/ioutil" |
9 "os" | 10 "os" |
10 "path/filepath" | 11 "path/filepath" |
11 "strconv" | 12 "strconv" |
12 "sync" | 13 "sync" |
13 "time" | 14 "time" |
14 | 15 |
15 "go.skia.org/infra/go/exec" | 16 "go.skia.org/infra/go/exec" |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
230 // happening chrome zombie processes are periodically killed. | 231 // happening chrome zombie processes are periodically killed. |
231 func ChromeProcessesCleaner(locker sync.Locker, chromeCleanerTimer time.Duration ) { | 232 func ChromeProcessesCleaner(locker sync.Locker, chromeCleanerTimer time.Duration ) { |
232 for _ = range time.Tick(chromeCleanerTimer) { | 233 for _ = range time.Tick(chromeCleanerTimer) { |
233 glog.Info("The chromeProcessesCleaner goroutine has started") | 234 glog.Info("The chromeProcessesCleaner goroutine has started") |
234 glog.Info("Waiting for all existing tasks to complete before kil ling zombie chrome processes") | 235 glog.Info("Waiting for all existing tasks to complete before kil ling zombie chrome processes") |
235 locker.Lock() | 236 locker.Lock() |
236 util.LogErr(ExecuteCmd("pkill", []string{"-9", "chrome"}, []stri ng{}, PKILL_TIMEOUT, nil, nil)) | 237 util.LogErr(ExecuteCmd("pkill", []string{"-9", "chrome"}, []stri ng{}, PKILL_TIMEOUT, nil, nil)) |
237 locker.Unlock() | 238 locker.Unlock() |
238 } | 239 } |
239 } | 240 } |
241 | |
242 type PagesetVars struct { | |
dogben
2015/10/15 13:51:57
Nit: documentation.
rmistry
2015/10/15 14:21:56
Done.
| |
243 UrlsList string `json:"urls_list"` | |
244 UserAgent string `json:"user_agent"` | |
245 ArchiveDataFile string `json:"archive_data_file"` | |
246 } | |
247 | |
248 func ReadPageset(pagesetPath string) (PagesetVars, error) { | |
249 decodedPageset := PagesetVars{} | |
250 pagesetContent, err := os.Open(pagesetPath) | |
251 if err != nil { | |
252 return decodedPageset, fmt.Errorf("Could not read %s: %s", pages etPath, err) | |
253 } | |
254 if err := json.NewDecoder(pagesetContent).Decode(&decodedPageset); err ! = nil { | |
255 return decodedPageset, fmt.Errorf("Could not JSON decode %s: %s" , pagesetPath, err) | |
256 } | |
257 return decodedPageset, nil | |
258 } | |
OLD | NEW |