Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add schedule management commands #3237

Merged
merged 1 commit into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions website/management/commands/run_daily.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import logging

from django.core.management.base import BaseCommand

# from django.core import management
from django.utils import timezone

logger = logging.getLogger(__name__)


class Command(BaseCommand):
help = "Runs commands scheduled to execute daily"

def handle(self, *args, **options):
try:
logger.info(f"Starting daily scheduled tasks at {timezone.now()}")

# Add commands to be executed daily
# management.call_command('daily_command1')
# management.call_command('daily_command2')
except Exception as e:
logger.error(f"Error in daily tasks: {str(e)}")
raise
23 changes: 23 additions & 0 deletions website/management/commands/run_hourly.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import logging

from django.core.management.base import BaseCommand

# from django.core import management
from django.utils import timezone

logger = logging.getLogger(__name__)


class Command(BaseCommand):
help = "Runs commands scheduled to execute hourly"

def handle(self, *args, **options):
try:
logger.info(f"Starting hourly scheduled tasks at {timezone.now()}")

# We can add hourly commands here
# management.call_command('hourly_command1')
# management.call_command('hourly_command2')
except Exception as e:
logger.error(f"Error in hourly tasks: {str(e)}")
raise
23 changes: 23 additions & 0 deletions website/management/commands/run_monthly.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import logging

from django.core.management.base import BaseCommand

# from django.core import management
from django.utils import timezone

logger = logging.getLogger(__name__)


class Command(BaseCommand):
help = "Runs commands scheduled to execute monthly"

def handle(self, *args, **options):
try:
logger.info(f"Starting monthly scheduled tasks at {timezone.now()}")

# Add commands to be executed monthly
# management.call_command('monthly_command1')
# management.call_command('monthly_command2')
except Exception as e:
logger.error(f"Error in monthly tasks: {str(e)}")
raise
23 changes: 23 additions & 0 deletions website/management/commands/run_weekly.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import logging

from django.core.management.base import BaseCommand

# from django.core import management
from django.utils import timezone

logger = logging.getLogger(__name__)


class Command(BaseCommand):
help = "Runs commands scheduled to execute weekly"

def handle(self, *args, **options):
try:
logger.info(f"Starting weekly scheduled tasks at {timezone.now()}")

# Add commands to be executed weekly
# management.call_command('weekly_command1')
# management.call_command('weekly_command2')
except Exception as e:
logger.error(f"Error in weekly tasks: {str(e)}")
raise
Loading