Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F93248377
PhabricatorDaemonOverseerModule.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Wed, Nov 27, 08:27
Size
1 KB
Mime Type
text/x-php
Expires
Fri, Nov 29, 08:27 (2 d)
Engine
blob
Format
Raw Data
Handle
22597003
Attached To
rPH Phabricator
PhabricatorDaemonOverseerModule.php
View Options
<?php
/**
* Overseer module.
*
* The primary purpose of this overseer module is to poll for configuration
* changes and reload daemons when the configuration changes.
*/
final
class
PhabricatorDaemonOverseerModule
extends
PhutilDaemonOverseerModule
{
private
$configVersion
;
public
function
shouldReloadDaemons
()
{
if
(
$this
->
shouldThrottle
(
'reload'
,
10
))
{
return
false
;
}
return
$this
->
updateConfigVersion
();
}
/**
* Calculate a version number for the current Phabricator configuration.
*
* The version number has no real meaning and does not provide any real
* indication of whether a configuration entry has been changed. The config
* version is intended to be a rough indicator that "something has changed",
* which indicates to the overseer that the daemons should be reloaded.
*
* @return int
*/
private
function
loadConfigVersion
()
{
$conn_r
=
id
(
new
PhabricatorConfigEntry
())->
establishConnection
(
'r'
);
return
head
(
queryfx_one
(
$conn_r
,
'SELECT MAX(id) FROM %T'
,
id
(
new
PhabricatorConfigTransaction
())->
getTableName
()));
}
/**
* Check and update the configuration version.
*
* @return bool True if the daemons should restart, otherwise false.
*/
private
function
updateConfigVersion
()
{
$old_version
=
$this
->
configVersion
;
$new_version
=
$this
->
loadConfigVersion
();
$this
->
configVersion
=
$new_version
;
// Don't trigger a reload if we're loading the config for the very
// first time.
if
(
$old_version
===
null
)
{
return
false
;
}
return
(
$old_version
!=
$new_version
);
}
}
Event Timeline
Log In to Comment