Skip to content

Conversation

@jumski
Copy link
Contributor

@jumski jumski commented Dec 5, 2025

Add setup_ensure_workers_cron function for automated worker management

This PR adds a new setup_ensure_workers_cron function that automates worker management by setting up two cron jobs:

  1. pgflow_ensure_workers - Runs the ensure_workers() function at a configurable interval (default: every 1 second)
  2. pgflow_cleanup_logs - Runs hourly to clean up old cron job logs

The function is idempotent - it safely replaces any existing jobs with the same names and returns a confirmation message with job IDs. This makes worker management more reliable and reduces manual intervention.

Key features:

  • Configurable interval for worker checks via the cron_interval parameter
  • Automatic cleanup of old logs to prevent database bloat
  • Comprehensive test coverage for all functionality
  • TypeScript type definitions for the new function

This enables more reliable worker management in production environments.

@changeset-bot
Copy link

changeset-bot bot commented Dec 5, 2025

⚠️ No Changeset found

Latest commit: dc5db88

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor Author

jumski commented Dec 5, 2025

@nx-cloud
Copy link

nx-cloud bot commented Dec 5, 2025

View your CI Pipeline Execution ↗ for commit dc5db88

Command Status Duration Result
nx run edge-worker:test:integration ✅ Succeeded 3m 42s View ↗
nx run client:e2e ✅ Succeeded 1m 9s View ↗
nx run cli:e2e ✅ Succeeded 3s View ↗
nx affected -t verify-exports --base=origin/mai... ✅ Succeeded 3s View ↗
nx affected -t build --configuration=production... ✅ Succeeded 24s View ↗
nx affected -t lint typecheck test --parallel -... ✅ Succeeded 22s View ↗
nx run edge-worker:e2e ✅ Succeeded 36s View ↗
nx run core:pgtap ✅ Succeeded <1s View ↗

☁️ Nx Cloud last updated this comment at 2025-12-08 09:24:37 UTC

@jumski jumski force-pushed the 12-05-add_cleanup_ensure_workers_logs_sql_function_for_cron_job_log_maintenance branch from 6232598 to ac3a640 Compare December 5, 2025 22:53
@jumski jumski force-pushed the 12-05-add_setup_ensure_workers_cron_sql_function_for_cron_job_scheduling branch from 1f0dbdd to 133efc3 Compare December 5, 2025 22:53
@jumski jumski force-pushed the 12-05-add_setup_ensure_workers_cron_sql_function_for_cron_job_scheduling branch from 133efc3 to 31944b5 Compare December 7, 2025 00:32
@jumski jumski force-pushed the 12-05-add_cleanup_ensure_workers_logs_sql_function_for_cron_job_log_maintenance branch from ac3a640 to 28eab2e Compare December 7, 2025 00:32
@jumski jumski force-pushed the 12-05-add_setup_ensure_workers_cron_sql_function_for_cron_job_scheduling branch from 31944b5 to d43f53b Compare December 7, 2025 16:45
@jumski jumski force-pushed the 12-05-add_setup_ensure_workers_cron_sql_function_for_cron_job_scheduling branch from d43f53b to aca53bc Compare December 8, 2025 05:23
@jumski jumski force-pushed the 12-05-add_cleanup_ensure_workers_logs_sql_function_for_cron_job_log_maintenance branch from 19991aa to a7d6936 Compare December 8, 2025 05:23
@github-actions
Copy link
Contributor

github-actions bot commented Dec 8, 2025

🔍 Preview Deployment: Website

Deployment successful!

🔗 Preview URL: https://pr-512.pgflow.pages.dev

📝 Details:

  • Branch: 12-05-add_setup_ensure_workers_cron_sql_function_for_cron_job_scheduling
  • Commit: aa8f15cf4f4ac5837431d16ec6702097f90a1c61
  • View Logs

_Last updated: _

Copy link
Contributor Author

jumski commented Dec 8, 2025

Merge activity

  • Dec 8, 8:07 AM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Dec 8, 9:18 AM UTC: Graphite rebased this pull request as part of a merge.
  • Dec 8, 9:24 AM UTC: @jumski merged this pull request with Graphite.

@jumski jumski changed the base branch from 12-05-add_cleanup_ensure_workers_logs_sql_function_for_cron_job_log_maintenance to graphite-base/512 December 8, 2025 09:09
@jumski jumski changed the base branch from graphite-base/512 to main December 8, 2025 09:16
@jumski jumski force-pushed the 12-05-add_setup_ensure_workers_cron_sql_function_for_cron_job_scheduling branch from aca53bc to dc5db88 Compare December 8, 2025 09:17
@jumski jumski merged commit 460223e into main Dec 8, 2025
11 of 13 checks passed
@github-actions
Copy link
Contributor

github-actions bot commented Dec 8, 2025

🚀 Production Deployment: Website

Successfully deployed to production!

🔗 Production URL: https://pgflow.dev

📝 Details:

  • Commit: 460223e02de2aa6ae0752b08e24f0303e383bf23
  • View Logs

Deployed at: 2025-12-08T10:24:25+01:00

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