Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ jobs:
GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }}
GPG_PASS: ${{secrets.GPG_PASS}}
CGO_ENABLED: 0
GOEXPERIMENT: greenteagc
LDFLAGS: >-
-s
-X github.com/roadrunner-server/roadrunner/v2025/internal/meta.version=${{ steps.values.outputs.version }}
Expand Down
38 changes: 0 additions & 38 deletions AGENTS.md

This file was deleted.

143 changes: 143 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## Project Overview

RoadRunner is a high-performance PHP application server and process manager written in Go. It supports running as a service with extensive plugin functionality for HTTP/2/3, gRPC, queues (RabbitMQ, Kafka, SQS, NATS), KV stores, WebSockets, Temporal workflows, and more.

## Development Commands

### Build
```bash
make build
# Or manually:
CGO_ENABLED=0 go build -trimpath -ldflags "-s" -o rr cmd/rr/main.go
```

### Test
```bash
make test
# Or manually:
go test -v -race ./...
```

### Debug
```bash
make debug
# Uses delve to debug with sample config
```

### Run RoadRunner
```bash
./rr serve -c .rr.yaml
```

### Other Commands
```bash
./rr workers # Show worker status
./rr workers -i # Interactive worker information
./rr reset # Reset workers
./rr jobs # Jobs management commands
./rr stop # Stop RoadRunner server
```

### Run Single Test
```bash
go test -v -race -run TestName ./path/to/package
```

## Architecture

### Plugin System

RoadRunner uses the **Endure** dependency injection container. All plugins are registered in `container/plugins.go:Plugins()`. The plugin architecture follows these principles:

1. **Plugin Registration**: Plugins are listed in `container/plugins.go` and automatically wired by Endure
2. **Plugin Dependencies**: Plugins declare dependencies via struct fields with interface types
3. **Initialization Order**: Endure resolves the dependency graph and initializes plugins in correct order

### Key Components

- **`cmd/rr/main.go`**: Entry point that delegates to CLI commands
- **`internal/cli/`**: CLI command implementations (serve, workers, reset, jobs, stop)
- **`container/`**: Plugin registration and Endure container configuration
- **Plugin packages**: External packages under `github.com/roadrunner-server/*` (imported in go.mod)

### Configuration

- Primary config: `.rr.yaml` (extensive sample provided)
- Version 3 config format required (`version: '3'`)
- Environment variable substitution supported: `${ENVIRONMENT_VARIABLE_NAME}`
- Sample configs: `.rr-sample-*.yaml` for different use cases (HTTP, gRPC, Temporal, Kafka, etc.)

### Core Plugins

**Server Management:**
- `server`: Worker pool management (NewWorker, NewWorkerPool)
- `rpc`: RPC server for PHP-to-Go communication (default: tcp://127.0.0.1:6001)
- `logger`: Logging infrastructure
- `informer`: Worker status reporting
- `resetter`: Worker reset functionality

**Protocol Servers:**
- `http`: HTTP/1/2/3 and FastCGI server with middleware support
- `grpc`: gRPC server
- `tcp`: Raw TCP connection handling

**Jobs/Queue Drivers:**
- `jobs`: Core jobs plugin
- `amqp`, `sqs`, `nats`, `kafka`, `beanstalk`: Queue backends
- `gps`: Google Pub/Sub

**KV Stores:**
- `kv`: Core KV plugin
- `memory`, `boltdb`, `redis`, `memcached`: Storage backends

**HTTP Middleware:**
- `static`, `headers`, `gzip`, `prometheus`, `send`, `proxy_ip_parser`, `otel`, `fileserver`

**Other:**
- `temporal`: Temporal.io workflow engine integration
- `centrifuge`: WebSocket/Broadcast via Centrifugo
- `lock`: Distributed locks
- `metrics`: Prometheus metrics
- `service`: Systemd-like service manager

### Worker Communication

RoadRunner communicates with PHP workers via:
- **Goridge protocol**: Binary protocol over pipes, TCP, or Unix sockets
- **RPC**: For management operations (reset, stats, etc.)
- Workers are PHP processes that implement the RoadRunner worker protocol

### Testing

- Tests use standard Go testing with `-race` flag
- Test files follow `*_test.go` convention
- Sample configs in `.rr-sample-*.yaml` are used for integration tests
- Test directories: `container/test`, `internal/rpc/test`

## Important Notes

- Go version: 1.25+ required (see go.mod)
- Module path: `github.com/roadrunner-server/roadrunner/v2025`
- Some versions are explicitly excluded in go.mod (e.g., go-redis v9.15.0, viper v1.18.x)
- Debug mode available via `--debug` flag (starts debug server on :6061)
- Config overrides supported via `-o dot.notation=value` flag
- Working directory can be set with `-w` flag
- `.env` file support via `--dotenv` flag or `DOTENV_PATH` environment variable

## Adding New Plugins

1. Import the plugin package in `container/plugins.go`
2. Add plugin instance to the `Plugins()` slice
3. Plugin must implement appropriate RoadRunner plugin interfaces
4. Endure will handle dependency injection and lifecycle management

## Configuration Patterns

- Each plugin has its own configuration section (named after plugin)
- Pools configuration is consistent across plugins (num_workers, max_jobs, timeouts, supervisor)
- TLS configuration follows similar pattern across plugins
- Most plugins support graceful shutdown via timeouts
3 changes: 0 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ ENV LDFLAGS="-s \
-X github.com/roadrunner-server/roadrunner/v2025/internal/meta.version=$APP_VERSION \
-X github.com/roadrunner-server/roadrunner/v2025/internal/meta.buildTime=$BUILD_TIME"

# enable Go greentea GC experiment during build
ENV GOEXPERIMENT=greenteagc

# compile binary file
RUN set -x
RUN go mod download
Expand Down
2 changes: 2 additions & 0 deletions container/plugins.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/roadrunner-server/beanstalk/v5"
"github.com/roadrunner-server/boltdb/v5"
"github.com/roadrunner-server/centrifuge/v5"
"github.com/roadrunner-server/fileserver/v5"
gps "github.com/roadrunner-server/google-pub-sub/v5"
grpcPlugin "github.com/roadrunner-server/grpc/v5"
"github.com/roadrunner-server/gzip/v5"
Expand Down Expand Up @@ -82,6 +83,7 @@ func Plugins() []any { //nolint:funlen
&send.Plugin{},
&proxyIP.Plugin{},
&rrOtel.Plugin{},
&fileserver.Plugin{},
// ===================
// gRPC
&grpcPlugin.Plugin{},
Expand Down
35 changes: 21 additions & 14 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ require (
github.com/roadrunner-server/config/v5 v5.1.9
github.com/roadrunner-server/endure/v2 v2.6.2
github.com/roadrunner-server/errors v1.4.1
github.com/roadrunner-server/fileserver/v5 v5.1.9
github.com/roadrunner-server/google-pub-sub/v5 v5.1.9
github.com/roadrunner-server/goridge/v3 v3.8.3
github.com/roadrunner-server/grpc/v5 v5.2.3
Expand Down Expand Up @@ -57,6 +58,7 @@ require (

exclude (
github.com/redis/go-redis/v9 v9.15.0
github.com/redis/go-redis/v9 v9.15.1
github.com/spf13/viper v1.18.0
github.com/spf13/viper v1.18.1
go.temporal.io/api v1.26.1
Expand All @@ -68,18 +70,19 @@ require (
cloud.google.com/go/auth/oauth2adapt v0.2.8 // indirect
cloud.google.com/go/compute/metadata v0.9.0 // indirect
cloud.google.com/go/iam v1.5.2 // indirect
cloud.google.com/go/pubsub/v2 v2.0.0 // indirect
cloud.google.com/go/pubsub/v2 v2.1.0 // indirect
github.com/andybalholm/brotli v1.2.0 // indirect
github.com/aws/aws-sdk-go-v2 v1.39.2 // indirect
github.com/aws/aws-sdk-go-v2/config v1.31.11 // indirect
github.com/aws/aws-sdk-go-v2/credentials v1.18.15 // indirect
github.com/aws/aws-sdk-go-v2/config v1.31.12 // indirect
github.com/aws/aws-sdk-go-v2/credentials v1.18.16 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.18.9 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.9 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.9 // indirect
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.3 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.1 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.13.9 // indirect
github.com/aws/aws-sdk-go-v2/service/sqs v1.42.8 // indirect
github.com/aws/aws-sdk-go-v2/service/sso v1.29.5 // indirect
github.com/aws/aws-sdk-go-v2/service/sso v1.29.6 // indirect
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.35.1 // indirect
github.com/aws/aws-sdk-go-v2/service/sts v1.38.6 // indirect
github.com/aws/smithy-go v1.23.0 // indirect
Expand All @@ -92,6 +95,7 @@ require (
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/cenkalti/backoff/v5 v5.0.3 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/clipperhouse/uax29/v2 v2.2.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/emicklei/proto v1.14.2 // indirect
Expand All @@ -103,6 +107,7 @@ require (
github.com/go-ole/go-ole v1.3.0 // indirect
github.com/go-viper/mapstructure/v2 v2.4.0 // indirect
github.com/goccy/go-json v0.10.5 // indirect
github.com/gofiber/fiber/v2 v2.52.9 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/mock v1.7.0-rc.1 // indirect
github.com/google/s2a-go v0.1.9 // indirect
Expand All @@ -117,12 +122,12 @@ require (
github.com/libdns/libdns v1.1.1 // indirect
github.com/mattn/go-colorable v0.1.14 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.17 // indirect
github.com/mattn/go-runewidth v0.0.19 // indirect
github.com/mholt/acmez v1.2.0 // indirect
github.com/mholt/acmez/v3 v3.1.4 // indirect
github.com/miekg/dns v1.1.68 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/nats-io/nats.go v1.46.0 // indirect
github.com/nats-io/nats.go v1.46.1 // indirect
github.com/nats-io/nkeys v0.4.11 // indirect
github.com/nats-io/nuid v1.0.1 // indirect
github.com/nexus-rpc/sdk-go v0.4.0 // indirect
Expand All @@ -141,9 +146,9 @@ require (
github.com/quic-go/qpack v0.5.1 // indirect
github.com/quic-go/quic-go v0.54.1 // indirect
github.com/rabbitmq/amqp091-go v1.10.0 // indirect
github.com/redis/go-redis/extra/rediscmd/v9 v9.14.0 // indirect
github.com/redis/go-redis/extra/redisotel/v9 v9.14.0 // indirect
github.com/redis/go-redis/extra/redisprometheus/v9 v9.14.0 // indirect
github.com/redis/go-redis/extra/rediscmd/v9 v9.15.1 // indirect
github.com/redis/go-redis/extra/redisotel/v9 v9.15.1 // indirect
github.com/redis/go-redis/extra/redisprometheus/v9 v9.15.1 // indirect
github.com/redis/go-redis/v9 v9.14.0 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/roadrunner-server/context v1.1.0 // indirect
Expand All @@ -165,6 +170,8 @@ require (
github.com/twmb/franz-go/pkg/kmsg v1.11.2 // indirect
github.com/twmb/murmur3 v1.1.8 // indirect
github.com/uber-go/tally/v4 v4.1.17 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasthttp v1.66.0 // indirect
github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
github.com/yusufpapurcu/wmi v1.2.4 // indirect
Expand Down Expand Up @@ -208,12 +215,12 @@ require (
golang.org/x/text v0.29.0 // indirect
golang.org/x/time v0.13.0 // indirect
golang.org/x/tools v0.37.0 // indirect
google.golang.org/api v0.250.0 // indirect
google.golang.org/genproto v0.0.0-20250922171735-9219d122eba9 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20250922171735-9219d122eba9 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20250922171735-9219d122eba9 // indirect
google.golang.org/api v0.251.0 // indirect
google.golang.org/genproto v0.0.0-20250929231259-57b25ae835d4 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20250929231259-57b25ae835d4 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20250929231259-57b25ae835d4 // indirect
google.golang.org/grpc v1.75.1 // indirect
google.golang.org/protobuf v1.36.9 // indirect
google.golang.org/protobuf v1.36.10 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading
Loading