ttrss: Add management of postgresql daemon in a shared manner

- This allows ttrss to disabled postgresql if it is not needed by any other app
and enable postgresql if it is disabled and ttrss is being enabled.

Tests:

- When disabling ttrss and it is the last app using postgresql, it will be
disabled too.

- When disabling ttrss and it is not the last app using postgresql, it will not
be disabled too.

- When enabling ttrss if postgresql is disabled, it will be enabled too.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Sunil Mohan Adapa 2025-01-09 19:56:35 -08:00 committed by James Valleroy
parent 763b555e83
commit da90ba721e
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808

View File

@ -7,7 +7,7 @@ from django.utils.translation import gettext_lazy as _
from plinth import app as app_module
from plinth import cfg, frontpage, menu
from plinth.config import DropinConfigs
from plinth.daemon import Daemon
from plinth.daemon import Daemon, SharedDaemon
from plinth.modules.apache.components import Webserver
from plinth.modules.backups.components import BackupRestore
from plinth.modules.firewall.components import Firewall
@ -85,8 +85,11 @@ class TTRSSApp(app_module.App):
last_updated_version=5)
self.add(webserver)
daemon = Daemon('daemon-ttrss', 'tt-rss')
self.add(daemon)
daemon1 = SharedDaemon('shared-daemon-ttrss-postgresql', 'postgresql')
self.add(daemon1)
daemon2 = Daemon('daemon-ttrss', 'tt-rss')
self.add(daemon2)
users_and_groups = UsersAndGroups('users-and-groups-ttrss',
groups=groups)
@ -98,6 +101,7 @@ class TTRSSApp(app_module.App):
def enable(self):
"""Enable components and API access."""
super().enable()
privileged.enable_api_access()
# Try to set the domain to one of the available TLS domains
@ -107,8 +111,6 @@ class TTRSSApp(app_module.App):
domain = next(names.get_available_tls_domains(), None)
privileged.set_domain(domain)
super().enable()
def setup(self, old_version):
"""Install and configure the app."""
privileged.pre_setup()