diff -x .bzr -x '*.pyc' -x powernapd.patch -crB powernap//config powernap-new//config *** powernap//config 2011-11-08 11:39:08.710536000 +0100 --- powernap-new//config 2011-11-08 10:11:00.447270923 +0100 *************** *** 67,72 **** --- 67,79 ---- # DEBUG = 2 DEBUG = 0 + # The powernap daemon can watch for changes in the configuration file in + # /etc/powernap directory without having to restart it. + # The default value is n. + # WATCH_CONFIG = y + # WATCH_CONFIG = n + WATCH_CONFIG = n + ############################################################################ #### STAGE2 ACTION #### ############################################################################ diff -x .bzr -x '*.pyc' -x powernapd.patch -crB powernap//powernap/powernap.py powernap-new//powernap/powernap.py *** powernap//powernap/powernap.py 2011-11-08 11:39:08.710536000 +0100 --- powernap-new//powernap/powernap.py 2011-11-08 11:33:04.327154462 +0100 *************** *** 38,43 **** --- 38,44 ---- self.STAGE2_ACTION_METHOD = 4 self.MONITORS = [] self.WARN = False + self.WATCH_CONFIG = False self.stage2_action_enabled = False # Load default config file (/etc/powernap/config) self.load_config_file() *************** *** 104,109 **** --- 105,117 ---- if var == "warn": if value == "y" or value == "yes": self.WARN = True + else: + self.WARN = False + if var == "watch_config": + if value == "y" or value == "yes": + self.WATCH_CONFIG = True + else: + self.WATCH_CONFIG = False def set_stage2_values(self, var, value): if var == "stage2_action_method": diff -x .bzr -x '*.pyc' -x powernapd.patch -crB powernap//sbin/powernapd powernap-new//sbin/powernapd *** powernap//sbin/powernapd 2011-11-08 11:39:08.710536000 +0100 --- powernap-new//sbin/powernapd 2011-11-08 10:15:22.691264687 +0100 *************** *** 180,187 **** --- 180,192 ---- stage2_grace_seconds = int(powernap.STAGE2_ABSENT_SECONDS/4) unflag_powersave() users_warned = False + watch_config_timestamp = os.stat(powernap.CONFIG).st_mtime while 1: + if powernap.WATCH_CONFIG == True: + if watch_config_timestamp != os.stat(powernap.CONFIG).st_mtime: + powernap.load_config_file() + watch_config_timestamp = os.stat(powernap.CONFIG).st_mtime debug(logging.DEBUG, "Sleeping [%d] seconds" % powernap.INTERVAL_SECONDS) time.sleep(powernap.INTERVAL_SECONDS) # Examine monitor activity, compute absent time of each monitored monitor process