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

+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."""