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

fix(temporal): Handle SIGTERM correctly on worker cleanup #25505

Merged
merged 1 commit into from
Oct 10, 2024

Conversation

tomasfarias
Copy link
Contributor

Problem

Local devs may have realized that on stopping ./bin/start the underlying temporal-worker-django process wasn't stopping. This was because we were not properly handling SIGTERM as a coroutine was not awaited.

Changes

  • Cleanup ./bin/temporal-django-worker
  • Properly handle SIGTERM in async python.

👉 Stay up-to-date with PostHog coding conventions for a smoother review.

Does this work well for both Cloud and self-hosted?

How did you test this code?

Manually:

  1. run ./bin/start/
  2. CTRL+C
  3. ps | grep 'temporal', nothing pops up. Without code change, the process is still there.

@tomasfarias tomasfarias requested a review from a team October 10, 2024 10:22
Comment on lines +5 to +12
cleanup() {
echo "Stopping worker..."
if kill -0 "$worker_pid" >/dev/null 2>&1; then
kill "$worker_pid"
else
echo "Worker process is not running."
fi
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

In case this is cleanup outside this script, do not error.

Copy link
Contributor

Size Change: +46 B (0%)

Total Size: 1.13 MB

ℹ️ View Unchanged
Filename Size Change
frontend/dist/toolbar.js 1.13 MB +46 B (0%)

compressed-size-action

@tomasfarias tomasfarias merged commit cd98275 into master Oct 10, 2024
88 checks passed
@tomasfarias tomasfarias deleted the fix/temporal-worker-cleanup branch October 10, 2024 12:17
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