Commit 70bec418 authored by Erick Hitter's avatar Erick Hitter
Browse files

Reorg

parent 2abc70ea
......@@ -147,6 +147,36 @@ func getSites() ([]Site, error) {
}
}
func getInstanceInfo() (SiteInfo, error) {
raw, err := runWpCliCmd([]string{"cron-control", "orchestrate", "get-info", "--format=json"})
if err != nil {
return SiteInfo{}, err
}
jsonRes := make([]SiteInfo, 0)
if err = json.Unmarshal([]byte(raw), &jsonRes); err != nil {
return SiteInfo{}, err
}
return jsonRes[0], nil
}
func getMultisiteSites() ([]Site, error) {
raw, err := runWpCliCmd([]string{"site", "list", "--fields=url", "--archived=false", "--deleted=false", "--spam=false", "--format=json"})
if err != nil {
logger.Println(fmt.Sprintf("%+v\n", err))
return make([]Site, 0), err
}
jsonRes := make([]Site, 0)
if err = json.Unmarshal([]byte(raw), &jsonRes); err != nil {
logger.Println(fmt.Sprintf("%+v\n", err))
return make([]Site, 0), err
}
return jsonRes, nil
}
func queueSiteEvents(workerId int, sites <-chan string, queue chan<- Event) {
for site := range sites {
logger.Printf("getEvents-%d processing %s", workerId, site)
......@@ -192,36 +222,6 @@ func runEvents(workerId int, events <-chan Event) {
}
}
func getInstanceInfo() (SiteInfo, error) {
raw, err := runWpCliCmd([]string{"cron-control", "orchestrate", "get-info", "--format=json"})
if err != nil {
return SiteInfo{}, err
}
jsonRes := make([]SiteInfo, 0)
if err = json.Unmarshal([]byte(raw), &jsonRes); err != nil {
return SiteInfo{}, err
}
return jsonRes[0], nil
}
func getMultisiteSites() ([]Site, error) {
raw, err := runWpCliCmd([]string{"site", "list", "--fields=url", "--archived=false", "--deleted=false", "--spam=false", "--format=json"})
if err != nil {
logger.Println(fmt.Sprintf("%+v\n", err))
return make([]Site, 0), err
}
jsonRes := make([]Site, 0)
if err = json.Unmarshal([]byte(raw), &jsonRes); err != nil {
logger.Println(fmt.Sprintf("%+v\n", err))
return make([]Site, 0), err
}
return jsonRes, nil
}
func runWpCliCmd(subcommand []string) (string, error) {
subcommand = append(subcommand, "--allow-root", "--quiet", fmt.Sprintf("--path=%s", wpPath))
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment