Path: blob/master/src/infrastructure/daemon/overseer/PhabricatorDaemonOverseerModule.php
12241 views
<?php12/**3* Overseer module.4*5* The primary purpose of this overseer module is to poll for configuration6* changes and reload daemons when the configuration changes.7*/8final class PhabricatorDaemonOverseerModule9extends PhutilDaemonOverseerModule {1011private $configVersion;1213public function shouldReloadDaemons() {14if ($this->shouldThrottle('reload', 10)) {15return false;16}1718return $this->updateConfigVersion();19}2021/**22* Calculate a version number for the current Phabricator configuration.23*24* The version number has no real meaning and does not provide any real25* indication of whether a configuration entry has been changed. The config26* version is intended to be a rough indicator that "something has changed",27* which indicates to the overseer that the daemons should be reloaded.28*29* @return int30*/31private function loadConfigVersion() {32$conn_r = id(new PhabricatorConfigEntry())->establishConnection('r');33return head(queryfx_one(34$conn_r,35'SELECT MAX(id) FROM %T',36id(new PhabricatorConfigTransaction())->getTableName()));37}3839/**40* Check and update the configuration version.41*42* @return bool True if the daemons should restart, otherwise false.43*/44private function updateConfigVersion() {45$old_version = $this->configVersion;46$new_version = $this->loadConfigVersion();4748$this->configVersion = $new_version;4950// Don't trigger a reload if we're loading the config for the very51// first time.52if ($old_version === null) {53return false;54}5556return ($old_version != $new_version);57}5859}606162