Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Conversation

@loks0n
Copy link
Member

@loks0n loks0n commented Dec 23, 2025

No description provided.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 23, 2025

📝 Walkthrough

Walkthrough

This pull request makes four factual changes: replaces a numeric signal literal with the SIGINT constant in the HTTP process; removes a worker startup logging hook from worker initialization; converts multiple shell wrapper scripts to use exec php ... $@ (replacing the shell with the PHP/worker process instead of spawning a child); and updates composer.json to alias utopia-php/queue to dev-feat-workerstop as 0.11.1.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Description check ❓ Inconclusive No pull request description was provided by the author, making it impossible to assess whether a description exists and relates to the changeset. Add a pull request description explaining the purpose of the graceful worker changes, including details about signal handling improvements and worker lifecycle modifications.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat: graceful worker' directly relates to the main changes in the PR, which involve adding graceful shutdown capabilities through signal handling (SIGINT constant) and removing startup logging to allow cleaner worker termination.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat-graceful-worker

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link

github-actions bot commented Dec 23, 2025

Security Scan Results for PR

Docker Image Scan Results

Package Version Vulnerability Severity
libpng 1.6.51-r0 CVE-2025-66293 HIGH
libpng-dev 1.6.51-r0 CVE-2025-66293 HIGH

Source Code Scan Results

🎉 No vulnerabilities found!

@github-actions
Copy link

github-actions bot commented Dec 23, 2025

✨ Benchmark results

  • Requests per second: 1,221
  • Requests with 200 status code: 219,799
  • P99 latency: 0.158310902

⚡ Benchmark Comparison

Metric This PR Latest version
RPS 1,221 1,273
200 219,799 229,126
P99 0.158310902 0.160931266

@loks0n loks0n force-pushed the feat-graceful-worker branch from c0471e6 to 650e4d8 Compare December 23, 2025 16:41
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (7)
bin/worker-mails (1)

3-3: Same concern as bin/worker-messaging.

The exec usage is correct. The unquoted $@ has the same robustness consideration mentioned in the previous file review.

bin/queue-retry (1)

3-3: Same concern as bin/worker-messaging.

The exec usage is correct. The unquoted $@ has the same robustness consideration mentioned in the previous file review.

bin/worker-stats-resources (1)

3-3: Same concern as bin/worker-messaging.

The exec usage is correct. The unquoted $@ has the same robustness consideration mentioned in the previous file review.

bin/test (1)

3-3: Same concern as bin/worker-messaging.

The exec usage is correct. The unquoted $@ has the same robustness consideration mentioned in the previous file review.

bin/worker-migrations (1)

3-3: Same concern as bin/worker-messaging.

The exec usage is correct. The unquoted $@ has the same robustness consideration mentioned in the previous file review.

bin/worker-databases (1)

3-3: Same concern as bin/worker-messaging.

The exec usage is correct. The unquoted $@ has the same robustness consideration mentioned in the previous file review.

bin/worker-functions (1)

3-3: Same concern as bin/worker-messaging.

The exec usage is correct. The unquoted $@ has the same robustness consideration mentioned in the previous file review.

🧹 Nitpick comments (2)
bin/worker-messaging (1)

3-3: LGTM! Consider quoting $@ for robustness.

The use of exec to replace the shell process with the PHP process is correct and aligns with the PR's graceful worker shutdown objectives. This ensures signals are delivered directly to the PHP process rather than the intermediate shell.

For robustness, consider quoting the argument expansion: "$@" instead of $@. While this likely works fine for typical CLI usage, unquoted expansion can incorrectly split arguments containing whitespace.

Suggested improvement (applies to all similar bin/* scripts)
-exec php /usr/src/code/app/worker.php messaging $@
+exec php /usr/src/code/app/worker.php messaging "$@"
bin/queue-count-failed (1)

3-3: LGTM! Consider quoting $@ for robustness.

The exec replacement is correct. As a minor shell best practice, consider using "$@" (quoted) to properly handle arguments containing spaces or special characters, though the current usage works for typical invocations.

🔎 Optional: Shell best practice for argument forwarding
-exec php /usr/src/code/app/cli.php queue-count --type=failed $@
+exec php /usr/src/code/app/cli.php queue-count --type=failed "$@"

This pattern can be applied to all similar wrapper scripts if desired.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c0471e6 and 650e4d8.

⛔ Files ignored due to path filters (1)
  • composer.lock is excluded by !**/*.lock
📒 Files selected for processing (35)
  • app/http.php
  • app/worker.php
  • bin/doctor
  • bin/install
  • bin/maintenance
  • bin/migrate
  • bin/queue-count-failed
  • bin/queue-count-processing
  • bin/queue-count-success
  • bin/queue-retry
  • bin/realtime
  • bin/schedule-executions
  • bin/schedule-functions
  • bin/schedule-messages
  • bin/screenshot
  • bin/sdks
  • bin/specs
  • bin/ssl
  • bin/stats-resources
  • bin/test
  • bin/upgrade
  • bin/vars
  • bin/worker-audits
  • bin/worker-builds
  • bin/worker-certificates
  • bin/worker-databases
  • bin/worker-deletes
  • bin/worker-functions
  • bin/worker-mails
  • bin/worker-messaging
  • bin/worker-migrations
  • bin/worker-stats-resources
  • bin/worker-stats-usage
  • bin/worker-webhooks
  • composer.json
💤 Files with no reviewable changes (1)
  • app/worker.php
🚧 Files skipped from review as they are similar to previous changes (21)
  • bin/ssl
  • bin/queue-count-success
  • bin/queue-count-processing
  • bin/worker-webhooks
  • bin/maintenance
  • composer.json
  • bin/realtime
  • bin/schedule-executions
  • bin/schedule-functions
  • app/http.php
  • bin/worker-builds
  • bin/install
  • bin/vars
  • bin/worker-stats-usage
  • bin/upgrade
  • bin/migrate
  • bin/worker-deletes
  • bin/specs
  • bin/schedule-messages
  • bin/worker-audits
  • bin/doctor
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (20)
  • GitHub Check: E2E Service Test (Databases/Legacy)
  • GitHub Check: E2E Service Test (Health)
  • GitHub Check: E2E Service Test (GraphQL)
  • GitHub Check: E2E Service Test (VCS)
  • GitHub Check: E2E Service Test (Storage)
  • GitHub Check: E2E Service Test (FunctionsSchedule)
  • GitHub Check: E2E Service Test (Realtime)
  • GitHub Check: E2E Service Test (Sites)
  • GitHub Check: E2E Service Test (Avatars)
  • GitHub Check: E2E Service Test (Databases/TablesDB)
  • GitHub Check: E2E Shared Mode Service Test (Dev Keys) (Shared V2)
  • GitHub Check: E2E Shared Mode Service Test (Dev Keys) (Shared V1)
  • GitHub Check: E2E Shared Mode Service Test (Site Screenshots) (Shared V1)
  • GitHub Check: Unit Test
  • GitHub Check: E2E Service Test (Dev Keys)
  • GitHub Check: E2E Service Test (Site Screenshots)
  • GitHub Check: E2E General Test
  • GitHub Check: Benchmark
  • GitHub Check: CodeQL
  • GitHub Check: scan
🔇 Additional comments (4)
bin/sdks (1)

3-3: LGTM! Clean exec replacement for signal propagation.

Using exec correctly replaces the shell process with the PHP CLI process, ensuring signals (SIGTERM, SIGINT) reach the PHP process directly for graceful shutdown. This aligns perfectly with the PR's graceful worker objectives.

bin/worker-certificates (1)

3-3: LGTM! Worker wrapper correctly updated.

The exec replacement ensures the PHP worker process receives shutdown signals directly, enabling graceful termination.

bin/stats-resources (1)

3-3: LGTM! Consistent exec pattern applied.

bin/screenshot (1)

3-3: LGTM! Exec pattern correctly applied.

@loks0n loks0n force-pushed the feat-graceful-worker branch from 650e4d8 to 374bdbe Compare December 23, 2025 18:23
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 650e4d8 and 374bdbe.

⛔ Files ignored due to path filters (1)
  • composer.lock is excluded by !**/*.lock
📒 Files selected for processing (35)
  • app/http.php
  • app/worker.php
  • bin/doctor
  • bin/install
  • bin/maintenance
  • bin/migrate
  • bin/queue-count-failed
  • bin/queue-count-processing
  • bin/queue-count-success
  • bin/queue-retry
  • bin/realtime
  • bin/schedule-executions
  • bin/schedule-functions
  • bin/schedule-messages
  • bin/screenshot
  • bin/sdks
  • bin/specs
  • bin/ssl
  • bin/stats-resources
  • bin/test
  • bin/upgrade
  • bin/vars
  • bin/worker-audits
  • bin/worker-builds
  • bin/worker-certificates
  • bin/worker-databases
  • bin/worker-deletes
  • bin/worker-functions
  • bin/worker-mails
  • bin/worker-messaging
  • bin/worker-migrations
  • bin/worker-stats-resources
  • bin/worker-stats-usage
  • bin/worker-webhooks
  • composer.json
💤 Files with no reviewable changes (1)
  • app/worker.php
🚧 Files skipped from review as they are similar to previous changes (22)
  • bin/specs
  • app/http.php
  • bin/worker-stats-usage
  • bin/maintenance
  • bin/queue-count-processing
  • bin/queue-count-failed
  • bin/worker-builds
  • bin/install
  • bin/worker-certificates
  • bin/schedule-functions
  • bin/migrate
  • bin/worker-databases
  • bin/schedule-executions
  • bin/ssl
  • bin/schedule-messages
  • bin/realtime
  • bin/worker-functions
  • bin/worker-migrations
  • bin/worker-deletes
  • bin/screenshot
  • bin/worker-mails
  • bin/worker-webhooks
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-08-22T06:23:32.026Z
Learnt from: ItzNotABug
Repo: appwrite/appwrite PR: 10348
File: app/controllers/shared/api.php:546-546
Timestamp: 2025-08-22T06:23:32.026Z
Learning: In Appwrite's codebase, Utopia\Queue\Broker\Pool (aliased as BrokerPool) is a readonly class that implements both Publisher and Consumer interfaces, allowing it to be used directly in constructors expecting either interface type. This is extensively used throughout the codebase for queue operations.

Applied to files:

  • composer.json
📚 Learning: 2025-08-22T06:23:32.026Z
Learnt from: ItzNotABug
Repo: appwrite/appwrite PR: 10348
File: app/controllers/shared/api.php:546-546
Timestamp: 2025-08-22T06:23:32.026Z
Learning: In the Utopia Queue system, the Pool class implements both Publisher and Consumer interfaces, so BrokerPool (Pool) can be passed directly to constructors expecting Publisher parameters like Func::__construct(protected Publisher $publisher).

Applied to files:

  • composer.json
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (20)
  • GitHub Check: Benchmark
  • GitHub Check: E2E Service Test (Tokens)
  • GitHub Check: E2E Service Test (FunctionsSchedule)
  • GitHub Check: E2E Service Test (Functions)
  • GitHub Check: E2E Service Test (Databases/TablesDB)
  • GitHub Check: E2E Service Test (Webhooks)
  • GitHub Check: E2E Service Test (Projects)
  • GitHub Check: E2E Service Test (Health)
  • GitHub Check: E2E Service Test (Avatars)
  • GitHub Check: E2E Service Test (Console)
  • GitHub Check: E2E Service Test (Account)
  • GitHub Check: E2E Shared Mode Service Test (Dev Keys) (Shared V2)
  • GitHub Check: E2E Shared Mode Service Test (Dev Keys) (Shared V1)
  • GitHub Check: E2E Shared Mode Service Test (Site Screenshots) (Shared V1)
  • GitHub Check: Unit Test
  • GitHub Check: E2E Shared Mode Service Test (Site Screenshots) (Shared V2)
  • GitHub Check: E2E Service Test (Dev Keys)
  • GitHub Check: E2E Service Test (Site Screenshots)
  • GitHub Check: E2E General Test
  • GitHub Check: scan
🔇 Additional comments (8)
bin/worker-stats-resources (1)

3-3: LGTM! Improves signal handling for graceful shutdown.

Using exec replaces the shell process with the PHP process, ensuring signals (e.g., SIGTERM, SIGINT) are delivered directly to the worker for proper graceful shutdown. This is a best practice for wrapper scripts and aligns with the PR's objective.

bin/test (1)

3-3: Excellent change for graceful shutdown support.

The use of exec to replace the shell process with the PHP/phpunit process is a best practice that enables:

  • Direct signal delivery (SIGTERM, SIGINT) to the PHP process without shell intermediation
  • Proper exit code propagation
  • Correct PID handling in containerized environments

This change is essential for the graceful worker shutdown feature and aligns with the PR objectives.

bin/queue-retry (1)

3-3: Excellent change for graceful shutdown support.

The use of exec to replace the shell process with the PHP process is a best practice that enables:

  • Direct signal delivery (SIGTERM, SIGINT) to the PHP process without shell intermediation
  • Proper exit code propagation
  • Correct PID handling in containerized environments

This change is essential for the graceful worker shutdown feature and aligns with the PR objectives.

bin/upgrade (1)

3-3: Excellent change for graceful shutdown support.

The use of exec to replace the shell process with the PHP process is a best practice that enables:

  • Direct signal delivery (SIGTERM, SIGINT) to the PHP process without shell intermediation
  • Proper exit code propagation
  • Correct PID handling in containerized environments

This change is essential for the graceful worker shutdown feature and aligns with the PR objectives.

bin/doctor (1)

3-3: Excellent change for graceful shutdown support.

The use of exec to replace the shell process with the PHP process is a best practice that enables:

  • Direct signal delivery (SIGTERM, SIGINT) to the PHP process without shell intermediation
  • Proper exit code propagation
  • Correct PID handling in containerized environments

This change is essential for the graceful worker shutdown feature and aligns with the PR objectives.

bin/queue-count-success (1)

3-3: Excellent change for graceful shutdown support.

The use of exec to replace the shell process with the PHP process is a best practice that enables:

  • Direct signal delivery (SIGTERM, SIGINT) to the PHP process without shell intermediation
  • Proper exit code propagation
  • Correct PID handling in containerized environments

This change is essential for the graceful worker shutdown feature and aligns with the PR objectives.

bin/worker-messaging (1)

3-3: Excellent change for graceful shutdown support—particularly critical for worker processes.

The use of exec to replace the shell process with the PHP worker process is a best practice that enables:

  • Direct signal delivery (SIGTERM, SIGINT) to the worker process without shell intermediation
  • Proper exit code propagation
  • Correct PID handling in containerized environments

This is especially important for worker processes that need to gracefully complete ongoing tasks before shutdown.

bin/sdks (1)

3-3: Excellent change for graceful shutdown support.

The use of exec to replace the shell process with the PHP process is a best practice that enables:

  • Direct signal delivery (SIGTERM, SIGINT) to the PHP process without shell intermediation
  • Proper exit code propagation
  • Correct PID handling in containerized environments

This change is essential for the graceful worker shutdown feature and aligns with the PR objectives.

#!/bin/sh

php /usr/src/code/app/cli.php stats-resources $@
exec php /usr/src/code/app/cli.php stats-resources $@
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion | 🟠 Major

Quote $@ to preserve argument boundaries.

Consistent with other scripts—use "$@" to handle arguments with spaces or special characters correctly.

Proposed fix
-exec php /usr/src/code/app/cli.php stats-resources $@
+exec php /usr/src/code/app/cli.php stats-resources "$@"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
exec php /usr/src/code/app/cli.php stats-resources $@
exec php /usr/src/code/app/cli.php stats-resources "$@"
🤖 Prompt for AI Agents
In bin/stats-resources at line 3, the exec invocation uses unquoted $@ which can
break argument boundaries for params with spaces or special characters; update
the exec call to use "$@" instead (i.e., replace $@ with "$@") so all passed
arguments are preserved exactly when forwarding to php /usr/src/code/app/cli.php
stats-resources.

#!/bin/sh

php /usr/src/code/app/cli.php vars $@
exec php /usr/src/code/app/cli.php vars $@
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion | 🟠 Major

Quote $@ to preserve argument boundaries.

Using exec is the right approach for signal propagation. However, $@ should be quoted to correctly handle arguments containing spaces or special characters.

Proposed fix
-exec php /usr/src/code/app/cli.php vars $@
+exec php /usr/src/code/app/cli.php vars "$@"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
exec php /usr/src/code/app/cli.php vars $@
exec php /usr/src/code/app/cli.php vars "$@"
🤖 Prompt for AI Agents
In bin/vars around line 3, the exec invocation uses an unquoted $@ which can
break arguments with spaces or special characters; update the exec command to
pass the positional parameters as a single quoted expansion (i.e., use "$@") so
all arguments are preserved and signal propagation via exec remains intact.

#!/bin/sh

php /usr/src/code/app/worker.php audits $@
exec php /usr/src/code/app/worker.php audits $@
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion | 🟠 Major

Quote $@ to preserve argument boundaries.

Same issue as other scripts—unquoted $@ will break on arguments with spaces.

Proposed fix
-exec php /usr/src/code/app/worker.php audits $@
+exec php /usr/src/code/app/worker.php audits "$@"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
exec php /usr/src/code/app/worker.php audits $@
exec php /usr/src/code/app/worker.php audits "$@"
🤖 Prompt for AI Agents
In bin/worker-audits around line 3, the script calls exec php
/usr/src/code/app/worker.php audits $@ without quoting $@ which breaks arguments
containing spaces; update the exec invocation to use quoted "$@" so each
original argument is preserved as a separate parameter (i.e., replace $@ with
"$@" in the exec line).

"utopia-php/pools": "0.8.*",
"utopia-php/preloader": "0.2.*",
"utopia-php/queue": "0.11.*",
"utopia-php/queue": "dev-feat-workerstop as 0.11.1",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify the utopia-php/queue dev branch exists and check its recent activity

echo "=== Checking if the dev-feat-workerstop branch exists ==="
gh api repos/utopia-php/queue/branches/feat-workerstop --jq '.name' 2>&1 || echo "Branch check failed"

echo -e "\n=== Recent commits on feat-workerstop branch ==="
gh api repos/utopia-php/queue/commits?sha=feat-workerstop --jq '.[0:3] | .[] | "\(.commit.author.date) - \(.commit.message | split("\n")[0])"' 2>&1 || echo "Could not fetch commits"

echo -e "\n=== Check if version 0.11.1 tag exists ==="
gh api repos/utopia-php/queue/git/refs/tags/0.11.1 --jq '.ref' 2>&1 || echo "Tag 0.11.1 does not exist (expected for dev alias)"

echo -e "\n=== List recent tags in utopia-php/queue ==="
gh api repos/utopia-php/queue/tags --jq '.[0:5] | .[] | "\(.name)"' 2>&1 || echo "Could not fetch tags"

Repository: appwrite/appwrite

Length of output: 503


Consider using a stable version instead of dev branch alias, or clarify why newer releases cannot be used.

The feat-workerstop branch exists and is actively maintained (most recent commit Dec 16, 2025), which is positive for testing. However, there are more recent stable versions available:

  • 0.14.0 (latest)
  • 0.13.0
  • 0.12.1
  • 0.12.0
  • 0.11.3

Instead of using dev-feat-workerstop as 0.11.1, either:

  1. Use a recent stable version (e.g., ^0.14.0 or ^0.13.0) if the graceful worker stop feature is already included
  2. If this feature only exists on the dev branch, clarify in the PR description why it cannot be found in the recent stable releases and plan the upgrade path

Dev branch dependencies remain mutable and should not reach production.

🤖 Prompt for AI Agents
In composer.json around line 72, the dependency "utopia-php/queue":
"dev-feat-workerstop as 0.11.1" pins a dev branch under an alias; replace it
with a stable release or justify keeping the dev branch: either set the version
to a stable constraint (e.g., "^0.14.0" or "^0.13.0") if the required graceful
worker stop feature exists there, or if the feature only exists on
feat-workerstop, update the PR description to explain why stable releases cannot
be used, add a composer.json comment or developer note documenting this
temporary decision, and ensure composer.lock is committed (or consider forking
and tagging a stable release) so production does not pull a mutable dev branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.