Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for tcp sockets for php-fpm #26

Merged
merged 1 commit into from
Jun 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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