Skip to content

Conversation

@chinhld12
Copy link
Collaborator

What's this PR do?

  • Added static cronjob functionality to manage scheduled notifications and workflow tasks.

Key Changes

New Features

  • Implemented job scheduler system with cron pattern support
  • Added REST API endpoints for cronjob management
  • Created notification configuration system
  • Added timezone support for scheduled jobs

Added Files

  • apps/agent/src/api/api-routes.ts: REST API endpoints for managing cronjobs
  • apps/agent/src/constants/notification.ts: Notification configuration constants
  • apps/agent/src/lib/scheduler.ts: Core scheduler implementation
  • apps/agent/src/openapi/schema/cronjob.ts: OpenAPI schemas for cronjob endpoints

Modified Files

  • apps/agent/package.json: Added dependencies
    • Added croner for cron job scheduling
    • Reordered @prisma/client dependency
  • apps/agent/src/mastra/index.ts: Integrated API routes and scheduler initialization
  • apps/agent/src/mastra/workflows/github-notify-developer-about-pr-status.ts: Added sub-job activity checks

Dependencies Added

  • croner v9.0.0: Cron job scheduling library

API Endpoints

/refresh-cronjobs (GET)

  • Refreshes all configured cron jobs
  • Returns success/failure status with appropriate messages

/refresh-cronjobs/:id (GET)

  • Refreshes a specific cron job by ID
  • Requires job ID parameter

Technical Details

Scheduler Features

  • Job initialization with timezone support
  • Ability to refresh individual jobs
  • Sub-job activity monitoring
  • Graceful termination of running jobs
  • Cron expression validation
  • Error handling and logging
Screenshot 2025-04-23 at 17 03 30 Screenshot 2025-04-23 at 17 05 18

@chinhld12 chinhld12 requested a review from zlatanpham April 23, 2025 10:06
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