2008-02-11 23:38:31 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
require_once("../inc/bossa_db.inc");
|
|
|
|
|
2008-02-15 15:25:44 +00:00
|
|
|
$int_max = 2147483647;
|
|
|
|
|
|
|
|
function debug($x) {
|
|
|
|
//return;
|
|
|
|
echo "$x\n";
|
|
|
|
}
|
|
|
|
|
2008-07-14 19:13:19 +00:00
|
|
|
function do_pass() {
|
2008-02-15 15:25:44 +00:00
|
|
|
global $int_max;
|
2008-07-14 19:13:19 +00:00
|
|
|
$now = time();
|
|
|
|
$insts = BossaJobInst::enum("transition_time < $now");
|
|
|
|
if (!count($insts)) return false;
|
|
|
|
foreach ($insts as $inst) {
|
|
|
|
BossaDb::start_transaction();
|
|
|
|
$inst = BossaJobInst::lookup_id($inst->id);
|
|
|
|
// reread instance within transation
|
|
|
|
if ($inst->transition_time < $now) {
|
|
|
|
$job = BossaJob::lookup_id($inst->job_id);
|
|
|
|
$user = BoincUser::lookup_id($inst->user_id);
|
|
|
|
BossaUser::lookup($user);
|
|
|
|
if ($inst->finished_time) {
|
|
|
|
job_finished($job, $inst, $user);
|
2008-02-15 15:25:44 +00:00
|
|
|
} else {
|
2008-07-14 19:13:19 +00:00
|
|
|
job_timed_out($job, $inst, $user);
|
2008-02-15 15:25:44 +00:00
|
|
|
}
|
2008-02-12 20:33:05 +00:00
|
|
|
}
|
2008-07-14 19:13:19 +00:00
|
|
|
$inst->update("transition_time=$int_max");
|
|
|
|
BossaDb::commit();
|
2008-02-12 20:33:05 +00:00
|
|
|
}
|
2008-07-14 19:13:19 +00:00
|
|
|
return true;
|
2008-02-11 23:38:31 +00:00
|
|
|
}
|
|
|
|
|
2008-07-14 19:13:19 +00:00
|
|
|
$name = $argv[1];
|
|
|
|
$app = BossaApp::lookup("short_name='$name'");
|
|
|
|
if (!$app) {
|
|
|
|
echo "No app named $name\n";
|
|
|
|
exit;
|
2008-02-11 23:38:31 +00:00
|
|
|
}
|
|
|
|
|
2008-07-14 19:13:19 +00:00
|
|
|
$bs = "../inc/".$name.".inc";
|
|
|
|
require_once($bs);
|
|
|
|
while (1) {
|
|
|
|
if (!do_pass()) {
|
|
|
|
debug("Sleeping");
|
|
|
|
sleep(10);
|
2008-02-11 23:38:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|