diff --git a/tuned.py b/tuned.py index 35407d3..479094e 100755 --- a/tuned.py +++ b/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() diff --git a/tuned/controller.py b/tuned/controller.py index a020347..186f6a8 100644 --- a/tuned/controller.py +++ b/tuned/controller.py @@ -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 diff --git a/tuned/daemon.py b/tuned/daemon.py index 1cf261f..913ee5d 100644 --- a/tuned/daemon.py +++ b/tuned/daemon.py @@ -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() diff --git a/tuned/logs.py b/tuned/logs.py index d0c78d3..7917ffd 100644 --- a/tuned/logs.py +++ b/tuned/logs.py @@ -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): diff --git a/tuned/monitors/repository.py b/tuned/monitors/repository.py index c5d1ce3..7cff873 100644 --- a/tuned/monitors/repository.py +++ b/tuned/monitors/repository.py @@ -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)) diff --git a/tuned/plugins/plugin_cpu.py b/tuned/plugins/plugin_cpu.py index 89d8402..f2a54bc 100644 --- a/tuned/plugins/plugin_cpu.py +++ b/tuned/plugins/plugin_cpu.py @@ -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): diff --git a/tuned/plugins/plugin_disk.py b/tuned/plugins/plugin_disk.py index 61a5466..1a7868f 100644 --- a/tuned/plugins/plugin_disk.py +++ b/tuned/plugins/plugin_disk.py @@ -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") diff --git a/tuned/plugins/plugin_net.py b/tuned/plugins/plugin_net.py index e4d26c8..7c805aa 100644 --- a/tuned/plugins/plugin_net.py +++ b/tuned/plugins/plugin_net.py @@ -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() diff --git a/tuned/plugins/repository.py b/tuned/plugins/repository.py index f9cff6b..dca218f 100644 --- a/tuned/plugins/repository.py +++ b/tuned/plugins/repository.py @@ -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: