Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
WP Plugins
Cron-Control
Commits
00eefc73
Commit
00eefc73
authored
Jul 14, 2017
by
Erick Hitter
Browse files
Fix network ID implementation
parent
c8a6f1b4
Changes
2
Hide whitespace changes
Inline
Side-by-side
runner/README.md
View file @
00eefc73
...
...
@@ -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
...
...
runner/runner.go
View file @
00eefc73
...
...
@@ -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
()
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment