Skip to content

Commit

Permalink
Merge pull request #26 from Automattic/add/tcp-socket
Browse files Browse the repository at this point in the history
feat: add support for tcp sockets for php-fpm
  • Loading branch information
sjinks authored Jun 20, 2024
2 parents 9976231 + 64f2d1e commit 73ff46c
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions performer/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package performer
import (
"encoding/json"
"fmt"
"github.com/Automattic/cron-control-runner/logger"
"github.com/Automattic/cron-control-runner/metrics"
"io"
"math/rand"
"net/http"
Expand All @@ -13,6 +11,9 @@ import (
"strings"
"time"

"github.com/Automattic/cron-control-runner/logger"
"github.com/Automattic/cron-control-runner/metrics"

"github.com/yookoala/gofast"
)

Expand Down Expand Up @@ -58,12 +59,17 @@ func NewCLI(wpCLIPath string, wpPath string, fpmURL string, metrics metrics.Mana
if fpmURL != "" {
var err error
parsedURL, err := url.Parse(fpmURL)
if err != nil || parsedURL == nil || parsedURL.Scheme != "unix" || parsedURL.Path == "" {
if err != nil || parsedURL == nil || (parsedURL.Scheme == "unix" && parsedURL.Path == "") || ((parsedURL.Scheme == "tcp" || parsedURL.Scheme == "tcp4" || parsedURL.Scheme == "tcp6") && parsedURL.Host == "") {
logger.Errorf("problem parsing FPM url %q: %v", fpmURL, err)
panic(err)
}
logger.Infof("Using FPM runtime at %q", parsedURL)
performer.fpm = gofast.SimpleClientFactory(gofast.SimpleConnFactory(parsedURL.Scheme, parsedURL.Path))
proto := parsedURL.Scheme
address := parsedURL.Host
if proto == "unix" {
address = parsedURL.Path
}
performer.fpm = gofast.SimpleClientFactory(gofast.SimpleConnFactory(proto, address))
}

return performer
Expand Down

0 comments on commit 73ff46c

Please sign in to comment.