Cleanup plugins when changing profile
This commit is contained in:
parent
f8fdb488df
commit
762c30b97a
9 changed files with 16 additions and 6 deletions
6
tuned.py
6
tuned.py
|
|
@ -70,9 +70,6 @@ if __name__ == "__main__":
|
|||
|
||||
controller = tuned.Controller(config_file, debug)
|
||||
|
||||
tuned.utils.handle_signal(signal.SIGHUP, controller.switch_to_default_profile)
|
||||
tuned.utils.handle_signal([signal.SIGINT, signal.SIGTERM], controller.terminate)
|
||||
|
||||
if daemon:
|
||||
log.switch_to_file()
|
||||
if tuned.utils.daemonize(3):
|
||||
|
|
@ -81,4 +78,7 @@ if __name__ == "__main__":
|
|||
log.critical("cannot daemonize")
|
||||
sys.exit(1)
|
||||
|
||||
tuned.utils.handle_signal(signal.SIGHUP, controller.switch_to_default_profile)
|
||||
tuned.utils.handle_signal([signal.SIGINT, signal.SIGTERM], controller.terminate)
|
||||
|
||||
controller.run()
|
||||
|
|
|
|||
|
|
@ -81,9 +81,10 @@ class Controller(exports.interfaces.ExportableInterface):
|
|||
|
||||
def switch_to_default_profile(self):
|
||||
profile = self.get_default_profile()
|
||||
log.info("Switching to default profile: %s" % (profile))
|
||||
|
||||
if len(profile) != 0:
|
||||
return switch_profile(profile)
|
||||
return self.switch_profile(profile)
|
||||
return False
|
||||
|
||||
@property
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ class Daemon(object):
|
|||
monitors_repo = monitors.get_repository()
|
||||
plugins_repo = plugins.get_repository()
|
||||
|
||||
log.debug("Loading %s" % (self._config_file))
|
||||
self._profile = profile.Profile(manager, self._config_file)
|
||||
self._profile.load()
|
||||
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ class TunedLogger(logging.getLoggerClass()):
|
|||
def __init__(self, *args, **kwargs):
|
||||
super(self.__class__, self).__init__(*args, **kwargs)
|
||||
self.setLevel(logging.INFO)
|
||||
self.switch_to_console()
|
||||
self.switch_to_file()
|
||||
self.propagate = False
|
||||
|
||||
def set_level(self, level, default = logging.NOTSET):
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ class MonitorRepository(tuned.patterns.Singleton):
|
|||
assert isinstance(monitor, self._loader.interface)
|
||||
monitor.cleanup()
|
||||
|
||||
log.info(monitor._instances)
|
||||
if len(monitor._instances) == 0:
|
||||
self._monitors.remove(type(monitor))
|
||||
|
||||
|
|
|
|||
|
|
@ -28,6 +28,8 @@ class CPULatencyPlugin(tuned.plugins.Plugin):
|
|||
}
|
||||
|
||||
def cleanup(self):
|
||||
tuned.monitors.get_repository().delete(self._load_monitor)
|
||||
|
||||
os.close(self._cpu_latency_fd)
|
||||
|
||||
def update_tuning(self):
|
||||
|
|
|
|||
|
|
@ -131,6 +131,8 @@ class DiskPlugin(tuned.plugins.Plugin):
|
|||
def cleanup(self):
|
||||
log.debug("Cleanup")
|
||||
|
||||
tuned.monitors.get_repository().delete(self._load_monitor)
|
||||
|
||||
for dev in self.devidle.keys():
|
||||
if self.devidle[dev]["LEVEL"] > 0:
|
||||
os.system("hdparm -S0 -B255 /dev/"+dev+" > /dev/null 2>&1")
|
||||
|
|
|
|||
|
|
@ -76,6 +76,8 @@ class NetTuningPlugin(tuned.plugins.Plugin):
|
|||
def cleanup(self):
|
||||
log.info("Cleanup")
|
||||
|
||||
tuned.monitors.get_repository().delete(self._load_monitor)
|
||||
|
||||
for dev in self.devidle.keys():
|
||||
if self.devidle[dev]["LEVEL"] > 0:
|
||||
ethcard(dev).set_max_speed()
|
||||
|
|
|
|||
|
|
@ -33,8 +33,9 @@ class PluginRepository(tuned.patterns.Singleton):
|
|||
|
||||
def delete(self, plugin):
|
||||
assert isinstance(plugin, self._loader.interface)
|
||||
plugin.cleanup()
|
||||
log.debug("removing plugin %s" % plugin)
|
||||
self._plugins.remove(plugin)
|
||||
plugin.cleanup()
|
||||
|
||||
def update(self):
|
||||
for plugin in self._plugins:
|
||||
|
|
|
|||
Loading…
Reference in a new issue