Creating and Managing Jobs
Jobs are the core building blocks of the Trigger.dev integration. This guide explains how to create, organize, and manage jobs in yourzopio
application.
Job Structure
In thezopio
framework, jobs are organized in a dedicated directory structure:
Creating a Job
To create a new job, follow these steps:- Create a new file in the
app/trigger/jobs
directory or add to an existing file - Import the necessary dependencies
- Define your job using the Trigger.dev client
Job Types
Trigger.dev supports various types of jobs:Event-Triggered Jobs
Jobs that run in response to specific events:Scheduled Jobs
Jobs that run on a schedule:Webhook-Triggered Jobs
Jobs that run in response to external webhooks:Job Versioning
When updating a job, it’s important to increment the version number to ensure proper handling of in-flight jobs:Job Organization
For larger applications, it’s recommended to organize jobs by domain:user-jobs.ts
- Jobs related to user managementpayment-jobs.ts
- Jobs related to paymentsnotification-jobs.ts
- Jobs related to notifications
index.ts
file:
Job Dependencies
Jobs can depend on external services or integrations:Testing Jobs
To test a job, you can send an event that triggers it:Job Monitoring
You can monitor your jobs in the Trigger.dev dashboard, which provides:- Real-time job execution status
- Detailed logs for each run
- Performance metrics
- Error tracking