glib: Refactor schedule debugging in a central place

Tests:

- Print the interval time in schedule() method and verify that the times are as
expected in develop mode and production mode.

- Notification shows up for RAM usage if the check hardcoded to True.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Sunil Mohan Adapa authored and James Valleroy committed 2023-10-21 18:43:20 -04:00
1 parent 2795e2d994
commit 2bf4271e04
6 files changed
+22 -25

No files matched your search

+2 -4
View File
@@ -56,10 +56,8 @@ class BackupsApp(app_module.App):
@staticmethod
def post_init():
"""Perform post initialization operations."""
# Check every hour (every 3 minutes in debug mode) to perform scheduled
# backups.
interval = 180 if cfg.develop else 3600
glib.schedule(interval, backup_by_schedule)
# Check every hour to perform scheduled backups
glib.schedule(3600, backup_by_schedule)
def setup(self, old_version):
"""Install and configure the app."""
+3 -5
View File
@@ -13,7 +13,7 @@ from django.utils.translation import gettext_lazy as _
from django.utils.translation import gettext_noop
from plinth import app as app_module
from plinth import cfg, daemon, glib, menu
from plinth import daemon, glib, menu
from plinth import operation as operation_module
from plinth.modules.apache.components import diagnose_url_on_all
from plinth.modules.backups.components import BackupRestore
@@ -63,12 +63,10 @@ class DiagnosticsApp(app_module.App):
def post_init():
"""Perform post initialization operations."""
# Check periodically for low RAM space
interval = 180 if cfg.develop else 3600
glib.schedule(interval, _warn_about_low_ram_space)
glib.schedule(3600, _warn_about_low_ram_space)
# Run diagnostics once a day
interval = 180 if cfg.develop else 86400
glib.schedule(interval, start_diagnostics, in_thread=False)
glib.schedule(24 * 3600, start_diagnostics, in_thread=False)
def setup(self, old_version):
"""Install and configure the app."""
+2 -4
View File
@@ -90,10 +90,8 @@ class DynamicDNSApp(app_module.App):
for domain_name in config['domains']:
notify_domain_added(domain_name)
# Check every 5 minutes (every 3 minutes in debug mode) to perform
# dynamic DNS updates.
interval = 180 if cfg.develop else 300
glib.schedule(interval, update_dns)
# Check every 5 minutes to perform dynamic DNS updates.
glib.schedule(300, update_dns)
def setup(self, old_version):
"""Install and configure the app."""
+2 -3
View File
@@ -62,9 +62,8 @@ class StorageApp(app_module.App):
@staticmethod
def post_init():
"""Perform post initialization operations."""
# Check every hour for low disk space, every 3 minutes in debug mode
interval = 180 if cfg.develop else 3600
glib.schedule(interval, warn_about_low_disk_space)
# Check every hour for low disk space
glib.schedule(3600, warn_about_low_disk_space)
# Schedule initialization of UDisks2 initialization
glib.schedule(3, udisks2.init, repeat=False)
+6 -9
View File
@@ -95,16 +95,13 @@ class UpgradesApp(app_module.App):
"""Perform post initialization operations."""
self._show_new_release_notification()
# Check every day (every 3 minutes in debug mode):
# - backports becomes available -> configure it if selected by user
interval = 180 if cfg.develop else 24 * 3600
glib.schedule(interval, setup_repositories)
# Check every day if backports becomes available, then configure it if
# selected by user.
glib.schedule(24 * 3600, setup_repositories)
# Check every day (every 3 minutes in debug mode):
# - new stable release becomes available -> perform dist-upgrade if
# updates are enabled
interval = 180 if cfg.develop else 24 * 3600
glib.schedule(interval, check_dist_upgrade)
# Check every day if new stable release becomes available, then perform
# dist-upgrade if updates are enabled
glib.schedule(24 * 3600, check_dist_upgrade)
def _show_new_release_notification(self):
"""When upgraded to new release, show a notification."""