mirror of
https://github.com/chibicitiberiu/ytsm.git
synced 2024-02-24 05:43:31 +00:00
Fixed issue where scheduler was not initialized after setup wizard. Also fixed issue where global synchronization wasn't updated when the admin settings are changed.
This commit is contained in:
parent
070755f119
commit
f879583637
@ -148,10 +148,22 @@ def synchronize_subscription(subscription: Subscription):
|
||||
__lock.release()
|
||||
|
||||
|
||||
__global_sync_job = None
|
||||
|
||||
|
||||
def schedule_synchronize_global():
|
||||
global __global_sync_job
|
||||
|
||||
trigger = CronTrigger.from_crontab(appconfig.sync_schedule)
|
||||
job = scheduler.add_job(synchronize, trigger, max_instances=1, coalesce=True)
|
||||
log.info('Scheduled synchronize job job=%s', job.id)
|
||||
|
||||
if __global_sync_job is None:
|
||||
trigger = CronTrigger.from_crontab(appconfig.sync_schedule)
|
||||
__global_sync_job = scheduler.add_job(synchronize, trigger, max_instances=1, coalesce=True)
|
||||
|
||||
else:
|
||||
__global_sync_job.reschedule(trigger, max_instances=1, coalesce=True)
|
||||
|
||||
log.info('Scheduled synchronize job job=%s', __global_sync_job.id)
|
||||
|
||||
|
||||
def schedule_synchronize_now():
|
||||
|
@ -9,6 +9,9 @@ scheduler = BackgroundScheduler()
|
||||
|
||||
def initialize_scheduler():
|
||||
|
||||
if scheduler.running:
|
||||
return
|
||||
|
||||
logger = logging.getLogger('scheduler')
|
||||
executors = {
|
||||
'default': {
|
||||
|
@ -9,6 +9,8 @@ from django.urls import reverse_lazy
|
||||
from django.views.generic import FormView
|
||||
|
||||
from YtManagerApp.management.appconfig import appconfig
|
||||
from YtManagerApp.management.jobs.synchronize import schedule_synchronize_global
|
||||
from YtManagerApp.scheduler import initialize_scheduler
|
||||
from YtManagerApp.views.forms.auth import ExtendedAuthenticationForm
|
||||
from YtManagerApp.views.forms.first_time import WelcomeForm, ApiKeyForm, PickAdminUserForm, ServerConfigForm, DoneForm, UserCreationForm
|
||||
|
||||
@ -174,7 +176,11 @@ class Step3ConfigureView(WizardStepMixin, FormView):
|
||||
|
||||
# Set initialized to true
|
||||
appconfig.initialized = True
|
||||
|
||||
|
||||
# Start scheduler if not started
|
||||
initialize_scheduler()
|
||||
schedule_synchronize_global()
|
||||
|
||||
return super().form_valid(form)
|
||||
|
||||
|
||||
|
@ -3,6 +3,7 @@ from django.http import HttpResponseForbidden
|
||||
from django.urls import reverse_lazy
|
||||
from django.views.generic import FormView
|
||||
|
||||
from YtManagerApp.management.jobs.synchronize import schedule_synchronize_global
|
||||
from YtManagerApp.views.forms.settings import SettingsForm, AdminSettingsForm
|
||||
|
||||
|
||||
@ -44,4 +45,5 @@ class AdminSettingsView(LoginRequiredMixin, FormView):
|
||||
|
||||
def form_valid(self, form):
|
||||
form.save()
|
||||
schedule_synchronize_global()
|
||||
return super().form_valid(form)
|
||||
|
Loading…
Reference in New Issue
Block a user