Introduce uwsgi component to manage uWSGI configuration

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 2019-06-13 20:17:53 -04:00
1 parent 4100d36381
commit 862d87920a
7 files changed
+173 -28

No files matched your search

+38
View File
@@ -58,3 +58,41 @@ class Webserver(app.LeaderComponent):
actions.superuser_run(
'apache',
['disable', '--name', self.web_name, '--kind', self.kind])
class Uwsgi(app.LeaderComponent):
"""Component to enable/disable uWSGI configuration."""
def __init__(self, component_id, uwsgi_name):
"""Initialize the uWSGI component.
component_id should be a unique ID across all components of an app and
across all components.
uwsgi_name is the primary part of the configuration file path which must
be enabled/disabled by this component.
"""
super().__init__(component_id)
self.uwsgi_name = uwsgi_name
def is_enabled(self):
"""Return whether the uWSGI configuration is enabled."""
return action_utils.uwsgi_is_enabled(self.uwsgi_name) \
and action_utils.service_is_enabled('uwsgi')
def enable(self):
"""Enable the uWSGI configuration."""
actions.superuser_run('apache',
['uwsgi-enable', '--name', self.uwsgi_name])
def disable(self):
"""Disable the uWSGI configuration."""
actions.superuser_run('apache',
['uwsgi-disable', '--name', self.uwsgi_name])
def is_running(self):
"""Return whether the uWSGI daemon is running with configuration."""
return action_utils.uwsgi_is_enabled(self.uwsgi_name) \
and action_utils.service_is_running('uwsgi')