Skip to content

Commit 6ac6850

Browse files
add pause_processing managemenet command
1 parent 5b659db commit 6ac6850

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import logging
2+
3+
from django.core.management.base import BaseCommand
4+
from django.template.defaultfilters import pluralize
5+
6+
from scpca_portal.models import Job
7+
8+
logger = logging.getLogger()
9+
logger.setLevel(logging.INFO)
10+
logger.addHandler(logging.StreamHandler())
11+
12+
13+
class Command(BaseCommand):
14+
help = """Pauses all processing jobs and adds them to the pending queue."""
15+
16+
def handle(self, *args, **kwargs):
17+
self.pause_processing()
18+
19+
def pause_processing(self):
20+
terminated_jobs = Job.terminate_processing(reason="Processing paused on re-deploy.")
21+
retry_jobs = Job.create_retry_jobs(terminated_jobs)
22+
23+
retry_job_count = len(retry_jobs)
24+
logger.info(
25+
f"{retry_job_count} processing job{pluralize(retry_job_count)} were paused "
26+
"and added to the pending queue before deploy."
27+
)

0 commit comments

Comments
 (0)