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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ Only PHP files within the `--target-dir` directory will be tracked.

### HTTP API

After starting, an HTTP server runs on port 8080 with the following endpoints:
After starting, an HTTP server runs on port 8080 by default (configurable via `--listen`) with the following endpoints:

#### GET /v1/report
Returns a report of PHP files in the target directory and their compilation status.
Expand Down
7 changes: 5 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ const (
var targetDir string
var emitLogEvents bool
var rewriteRuleFlags []string
var listenAddr string
var rewriteRules []RewriteRule

// RewriteRule holds a compiled regex and its replacement string
Expand Down Expand Up @@ -365,6 +366,8 @@ func init() {
rootCmd.Flags().BoolVar(&emitLogEvents, "emit-log-events", false, "Enable emitting log events via OTLP")
rootCmd.Flags().StringArrayVar(&rewriteRuleFlags, "compiled-path-rewrite-rule", nil,
"Rewrite rule for compiled file paths (format: regex::replacement, can be specified multiple times)")
rootCmd.Flags().StringVar(&listenAddr, "listen", ":8080",
"HTTP server listen address (format: [host]:port, e.g. :8080, 127.0.0.1:8080, 0.0.0.0:9000)")
}

func main() {
Expand Down Expand Up @@ -504,8 +507,8 @@ func run(cmd *cobra.Command, args []string) error {
http.HandleFunc("/v1/report", handleReport)
http.HandleFunc("/v1/stats", handleStats)
go func() {
slog.Info("Starting HTTP server on :8080")
if err := http.ListenAndServe(":8080", nil); err != nil {
slog.Info("Starting HTTP server", "listen", listenAddr)
if err := http.ListenAndServe(listenAddr, nil); err != nil {
slog.Error("HTTP server error", "error", err)
}
}()
Expand Down
Loading