@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Daemons - add a config check for out of date daemon environment

Summary: Fixes T4881.

Test Plan: made a config change, saw the issue, restarted daemons and it went away

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: epriestley, Korvin

Maniphest Tasks: T4881

Differential Revision: https://secure.phabricator.com/D10339

+53
+2
resources/sql/autopatches/20140822.daemonenvhash.sql
··· 1 + ALTER TABLE {$NAMESPACE}_daemon.daemon_log 2 + ADD COLUMN `envHash` CHAR(40) NOT NULL DEFAULT '' AFTER `dateModified`;
+40
src/applications/config/check/PhabricatorSetupCheckDaemons.php
··· 31 31 'a', 32 32 array( 33 33 'href' => $doc_href, 34 + 'target' => '_blank' 34 35 ), 35 36 pht('Managing Daemons with phd'))); 36 37 ··· 42 43 ->addCommand('phabricator/ $ ./bin/phd start'); 43 44 } 44 45 46 + $environment_hash = PhabricatorEnv::calculateEnvironmentHash(); 47 + $all_daemons = id(new PhabricatorDaemonLogQuery()) 48 + ->setViewer(PhabricatorUser::getOmnipotentUser()) 49 + ->withStatus(PhabricatorDaemonLogQuery::STATUS_ALIVE) 50 + ->execute(); 51 + foreach ($all_daemons as $daemon) { 52 + if ($daemon->getEnvHash() != $environment_hash) { 53 + $doc_href = PhabricatorEnv::getDocLink( 54 + 'Managing Daemons with phd'); 55 + 56 + $summary = pht( 57 + 'You should restart the daemons. Their configuration is out of '. 58 + 'date.'); 59 + 60 + $message = pht( 61 + 'The Phabricator daemons are running with an out of date '. 62 + 'configuration. If you are making multiple configuration changes, '. 63 + 'you only need to restart the daemons once after the last change.'. 64 + "\n\n". 65 + 'Use %s to restart daemons. See %s for more information.', 66 + phutil_tag('tt', array(), 'bin/phd restart'), 67 + phutil_tag( 68 + 'a', 69 + array( 70 + 'href' => $doc_href, 71 + 'target' => '_blank' 72 + ), 73 + pht('Managing Daemons with phd'))); 74 + 75 + $this->newIssue('daemons.need-restarting') 76 + ->setShortName(pht('Daemons Need Restarting')) 77 + ->setName(pht('Phabricator Daemons Need Restarting')) 78 + ->setSummary($summary) 79 + ->setMessage($message) 80 + ->addCommand('phabricator/ $ ./bin/phd restart'); 81 + break; 82 + } 83 + } 45 84 } 85 + 46 86 }
+1
src/applications/daemon/event/PhabricatorDaemonEventListener.php
··· 39 39 ->setDaemon($event->getValue('daemonClass')) 40 40 ->setHost(php_uname('n')) 41 41 ->setPID(getmypid()) 42 + ->setEnvHash(PhabricatorEnv::calculateEnvironmentHash()) 42 43 ->setStatus(PhabricatorDaemonLog::STATUS_RUNNING) 43 44 ->setArgv($event->getValue('argv')) 44 45 ->setExplicitArgv($event->getValue('explicitArgv'))
+1
src/applications/daemon/storage/PhabricatorDaemonLog.php
··· 15 15 protected $pid; 16 16 protected $argv; 17 17 protected $explicitArgv = array(); 18 + protected $envHash; 18 19 protected $status; 19 20 20 21 public function getConfiguration() {
+9
src/infrastructure/env/PhabricatorEnv.php
··· 221 221 return $env; 222 222 } 223 223 224 + public static function calculateEnvironmentHash() { 225 + $keys = array_keys(self::getAllConfigKeys()); 226 + $values = array(); 227 + foreach ($keys as $key) { 228 + $values[$key] = self::getEnvConfigIfExists($key); 229 + } 230 + return PhabricatorHash::digest(json_encode($values)); 231 + } 232 + 224 233 225 234 /* -( Reading Configuration )---------------------------------------------- */ 226 235