Commit 00eefc73 authored by Erick Hitter's avatar Erick Hitter
Browse files

Fix network ID implementation

parent c8a6f1b4
......@@ -21,7 +21,7 @@ In addition to the REST API endpoints that can be used to run events, a Go-based
* `-log` string
* Log path, omit to log to Stdout (default `os.Stdout`)
* `-network` int
* WordPress network ID (default `1`)
* WordPress network ID, `0` to disable (default `0`)
* `-workers-get` int
* Number of workers to retrieve events (default `1`)
* Increase for multisite instances so that sites are retrieved in a timely manner
......
......@@ -54,7 +54,7 @@ const runEventsBreak time.Duration = time.Second * 10
func init() {
flag.StringVar(&wpCliPath, "cli", "/usr/local/bin/wp", "Path to WP-CLI binary")
flag.IntVar(&wpNetwork, "network", 1, "WordPress network ID")
flag.IntVar(&wpNetwork, "network", 0, "WordPress network ID, `0` to disable")
flag.StringVar(&wpPath, "wp", "/var/www/html", "Path to WordPress installation")
flag.IntVar(&workersGetEvents, "workers-get", 1, "Number of workers to retrieve events")
flag.IntVar(&workersRunEvents, "workers-run", 5, "Number of workers to run events")
......@@ -270,7 +270,7 @@ func getSiteEvents(site string) ([]Event, error) {
func runEvents(workerId int, events <-chan Event) {
for event := range events {
subcommand := []string{"cron-control", "orchestrate", "runner-only", "run", fmt.Sprintf("--timestamp=%d", event.Timestamp), fmt.Sprintf("--action=%s", event.Action), fmt.Sprintf("--instance=%s", event.Instance), fmt.Sprintf("--url=%s", event.Url), fmt.Sprintf("--network=%d", wpNetwork)}
subcommand := []string{"cron-control", "orchestrate", "runner-only", "run", fmt.Sprintf("--timestamp=%d", event.Timestamp), fmt.Sprintf("--action=%s", event.Action), fmt.Sprintf("--instance=%s", event.Instance), fmt.Sprintf("--url=%s", event.Url)}
runWpCliCmd(subcommand)
......@@ -284,6 +284,9 @@ func runEvents(workerId int, events <-chan Event) {
func runWpCliCmd(subcommand []string) (string, error) {
subcommand = append(subcommand, "--allow-root", "--quiet", fmt.Sprintf("--path=%s", wpPath))
if wpNetwork > 0 {
subcommand = append(subcommand, fmt.Sprintf("--network=%d", wpNetwork))
}
wpCli := exec.Command(wpCliPath, subcommand...)
wpOut, err := wpCli.CombinedOutput()
......
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