NestJS Application rebuild without affecting current running process

Viewed 240

I am using NestJS cron in my REST API application but I have a question. How can I stop cron without interrupting the cron that are currently running todo a new build to apply new changes into the code? For Example:

import { Injectable, Logger } from '@nestjs/common';
import { Cron } from '@nestjs/schedule';

@Injectable()
export class TasksService {
  private readonly logger = new Logger(TasksService.name);

  @Cron('45 * * * * *')
  handleCron() {
    //Long running process code
  }
}

This code should run uninterrupted. I am using PM2 for process management. Is there any way to apply new changes without restarting the application?

0 Answers
Related