Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F69978635
PhabricatorTaskmasterDaemon.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
Thu, Jul 4, 14:13
Size
1 KB
Mime Type
text/x-php
Expires
Sat, Jul 6, 14:13 (2 d)
Engine
blob
Format
Raw Data
Handle
18772945
Attached To
rPH Phabricator
PhabricatorTaskmasterDaemon.php
View Options
<?php
final
class
PhabricatorTaskmasterDaemon
extends
PhabricatorDaemon
{
protected
function
run
()
{
do
{
PhabricatorCaches
::
destroyRequestCache
();
$tasks
=
id
(
new
PhabricatorWorkerLeaseQuery
())
->
setLimit
(
1
)
->
execute
();
if
(
$tasks
)
{
$this
->
willBeginWork
();
foreach
(
$tasks
as
$task
)
{
$id
=
$task
->
getID
();
$class
=
$task
->
getTaskClass
();
$this
->
log
(
pht
(
'Working on task %d (%s)...'
,
$id
,
$class
));
$task
=
$task
->
executeTask
();
$ex
=
$task
->
getExecutionException
();
if
(
$ex
)
{
if
(
$ex
instanceof
PhabricatorWorkerPermanentFailureException
)
{
$this
->
log
(
pht
(
'Task %d was cancelled: %s'
,
$id
,
$ex
->
getMessage
()));
}
else
if
(
$ex
instanceof
PhabricatorWorkerYieldException
)
{
$this
->
log
(
pht
(
'Task %s yielded.'
,
$id
));
}
else
{
$this
->
log
(
pht
(
'Task %d failed!'
,
$id
));
throw
new
PhutilProxyException
(
pht
(
'Error while executing Task ID %d.'
,
$id
),
$ex
);
}
}
else
{
$this
->
log
(
pht
(
'Task %s complete! Moved to archive.'
,
$id
));
}
}
$sleep
=
0
;
}
else
{
// 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.
$this
->
willBeginIdle
();
$sleep
=
1
;
}
$this
->
sleep
(
$sleep
);
}
while
(!
$this
->
shouldExit
());
}
}
Event Timeline
Log In to Comment