Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15476756
D17559.id42229.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D17559.id42229.diff
View Options
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -3989,6 +3989,7 @@
'PhabricatorTOTPAuthFactor' => 'applications/auth/factor/PhabricatorTOTPAuthFactor.php',
'PhabricatorTOTPAuthFactorTestCase' => 'applications/auth/factor/__tests__/PhabricatorTOTPAuthFactorTestCase.php',
'PhabricatorTaskmasterDaemon' => 'infrastructure/daemon/workers/PhabricatorTaskmasterDaemon.php',
+ 'PhabricatorTaskmasterDaemonModule' => 'infrastructure/daemon/workers/PhabricatorTaskmasterDaemonModule.php',
'PhabricatorTestApplication' => 'applications/base/controller/__tests__/PhabricatorTestApplication.php',
'PhabricatorTestCase' => 'infrastructure/testing/PhabricatorTestCase.php',
'PhabricatorTestController' => 'applications/base/controller/__tests__/PhabricatorTestController.php',
@@ -9318,6 +9319,7 @@
'PhabricatorTOTPAuthFactor' => 'PhabricatorAuthFactor',
'PhabricatorTOTPAuthFactorTestCase' => 'PhabricatorTestCase',
'PhabricatorTaskmasterDaemon' => 'PhabricatorDaemon',
+ 'PhabricatorTaskmasterDaemonModule' => 'PhutilDaemonOverseerModule',
'PhabricatorTestApplication' => 'PhabricatorApplication',
'PhabricatorTestCase' => 'PhutilTestCase',
'PhabricatorTestController' => 'PhabricatorController',
diff --git a/src/infrastructure/daemon/workers/PhabricatorTaskmasterDaemon.php b/src/infrastructure/daemon/workers/PhabricatorTaskmasterDaemon.php
--- a/src/infrastructure/daemon/workers/PhabricatorTaskmasterDaemon.php
+++ b/src/infrastructure/daemon/workers/PhabricatorTaskmasterDaemon.php
@@ -43,6 +43,11 @@
$sleep = 0;
} else {
+
+ if ($this->shouldHibernate(60)) {
+ break;
+ }
+
// When there's no work, sleep for one second. The pool will
// autoscale down if we're continuously idle for an extended period
// of time.
diff --git a/src/infrastructure/daemon/workers/PhabricatorTaskmasterDaemonModule.php b/src/infrastructure/daemon/workers/PhabricatorTaskmasterDaemonModule.php
new file mode 100644
--- /dev/null
+++ b/src/infrastructure/daemon/workers/PhabricatorTaskmasterDaemonModule.php
@@ -0,0 +1,33 @@
+<?php
+
+final class PhabricatorTaskmasterDaemonModule
+ extends PhutilDaemonOverseerModule {
+
+ public function shouldWakePool(PhutilDaemonPool $pool) {
+ $class = $pool->getPoolDaemonClass();
+
+ if ($class != 'PhabricatorTaskmasterDaemon') {
+ return false;
+ }
+
+ if ($this->shouldThrottle($class, 1)) {
+ return false;
+ }
+
+ $table = new PhabricatorWorkerActiveTask();
+ $conn = $table->establishConnection('r');
+
+ $row = queryfx_one(
+ $conn,
+ 'SELECT id FROM %T WHERE leaseOwner IS NULL
+ OR leaseExpires <= %d LIMIT 1',
+ $table->getTableName(),
+ PhabricatorTime::getNow());
+ if (!$row) {
+ return false;
+ }
+
+ return true;
+ }
+
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Apr 8, 9:07 AM (2 w, 4 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7372252
Default Alt Text
D17559.id42229.diff (2 KB)
Attached To
Mode
D17559: Allow taskmaster daemons to hibernate
Attached
Detach File
Event Timeline
Log In to Comment