Skip to content

Conversation

@josbeir
Copy link
Contributor

@josbeir josbeir commented Dec 17, 2025

This PR adds support for running queue jobs in isolated subprocesses. That allows code changes to take effect immediately without restarting long‑running workers, speeding up iterative development and reducing workflow friction. Subprocess execution also contains job failures to the child process, improving stability of the main worker and making debugging safer and more predictable.

Key Features

Subprocess Execution: New SubprocessProcessor wraps the standard processor to execute jobs in isolated PHP processes via proc_open(), communicating job data and results over stdin using JSON.

CLI Command: SubprocessJobRunnerCommand handles single job execution within the subprocess, accepting job data via STDIN and returning results via STDOUT.

Worker Integration: Added --subprocess flag to WorkerCommand to enable subprocess mode. Also configurable via Queue.subprocess config key.

Configuration

// Enable globally
Configure::write('Queue.subprocess', true);

// Or use CLI flag
bin/cake queue worker --subprocess

Note about logging to stdout

As messaging between worker and sub command is using stdout with json i decided to redirect all other stdout logging to stderr. This seemed like a fine balance as subprocesses would only be used locally. And even if they where to be used in production for any reason (memory, crash resilience?) then a dedicated log engine could be used instead.

Copilot AI review requested due to automatic review settings December 17, 2025 14:06

This comment was marked as resolved.

@josbeir josbeir marked this pull request as draft December 17, 2025 14:47
@josbeir josbeir force-pushed the sub-process branch 2 times, most recently from c80bb73 to 849f868 Compare December 17, 2025 15:58
@josbeir josbeir self-assigned this Dec 17, 2025
@josbeir josbeir added the enhancement New feature or request label Dec 17, 2025
@josbeir josbeir added this to the 2.next milestone Dec 17, 2025
@josbeir josbeir marked this pull request as ready for review December 17, 2025 16:51
@josbeir josbeir requested review from ADmad and markstory December 17, 2025 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request needs squashing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants