1
0
Fork 0

Start dbus exports after a profile is applied

We should register to dbus after a profile is fully applied when
starting up. This makes systemd services depending on some tunings
performed by tuned (with After=tuned.service in their service file)
to start only after all tunings were applied.

Resolves: https://github.com/redhat-performance/tuned/issues/23
Resolves: rhbz#1443142

Signed-off-by: Ondřej Lysoněk <olysonek@redhat.com>
This commit is contained in:
Ondřej Lysoněk 2017-09-25 16:03:52 +02:00
parent 65b3cae0cc
commit d78565a205
4 changed files with 14 additions and 5 deletions

View file

@ -186,9 +186,7 @@ class Application(object):
# override global config if ran from command line with daemon option (-d)
if daemon:
self.config.set(consts.CFG_DAEMON, True)
if self.config.get_bool(consts.CFG_DAEMON, consts.CFG_DEF_DAEMON):
exports.start()
else:
if not self.config.get_bool(consts.CFG_DAEMON, consts.CFG_DEF_DAEMON):
log.warn("Using one shot no deamon mode, most of the functionality will be not available, it can be changed in global config")
result = self._controller.run()
if self.config.get_bool(consts.CFG_DAEMON, consts.CFG_DEF_DAEMON):

View file

@ -28,9 +28,12 @@ class Controller(tuned.exports.interfaces.ExportableInterface):
Controller main loop. The call is blocking.
"""
log.info("starting controller")
self.start()
res = self.start()
daemon = self._global_config.get_bool(consts.CFG_DAEMON, consts.CFG_DEF_DAEMON)
if not res and daemon:
exports.start()
if self._global_config.get_bool(consts.CFG_DAEMON, consts.CFG_DEF_DAEMON):
if daemon:
self._terminate.clear()
# we have to pass some timeout, otherwise signals will not work
while not self._cmd.wait(self._terminate, 3600):

View file

@ -6,6 +6,7 @@ from tuned.exceptions import TunedException
from tuned.profiles.exceptions import InvalidProfileException
import tuned.consts as consts
from tuned.utils.commands import commands
from tuned import exports
import re
log = tuned.logs.get()
@ -127,6 +128,8 @@ class Daemon(object):
self._unit_manager.start_tuning()
self._profile_applied.set()
log.info("static tuning from profile '%s' applied" % self._profile.name)
if self._daemon:
exports.start()
self._notify_profile_changed(self._profile.name, True, "OK")
if self._daemon:

View file

@ -56,6 +56,9 @@ class DBusExporter(interfaces.ExporterInterface):
def object_name(self):
return self._object_name
def running(self):
return self._thread is not None
def export(self, method, in_signature, out_signature):
if not inspect.ismethod(method):
raise Exception("Only bound methods can be exported.")
@ -129,6 +132,8 @@ class DBusExporter(interfaces.ExporterInterface):
self._dbus_object_cls = cls
def start(self):
if self.running():
return
if self._dbus_object_cls is None:
self._construct_dbus_object_class()