- Added a wait timeout parameter to the WAITING method, so that Spectre

doesn't have to check something that the workflow activity knows it will 
   have to wait on for a while.
 - Added --stop and --start aliases to spectre.pl.
This commit is contained in:
JT Smith 2008-11-19 01:15:31 +00:00
parent 7349633d63
commit bc5fd3c727
21 changed files with 89 additions and 44 deletions

View file

@ -381,7 +381,7 @@ sub execute {
if ($currentVersionTag) {
$currentVersionTag->setWorking;
}
return $self->WAITING;
return $self->WAITING(1);
}
my $eventData = shift @$eventList;
my $recur = $eventData->{recur};

View file

@ -119,7 +119,7 @@ sub execute {
}
}
# taking too long, give up
return $self->WAITING if (time() - $start > 50);
return $self->WAITING(1) if (time() - $start > 50);
}
# kill temporary files
@ -149,7 +149,7 @@ sub recurseFileSystem {
foreach my $file (@filelist) {
unless ($file eq "." || $file eq "..") {
# taking too long, time to abort
return $self->WAITING if (time() - $start > 50);
return $self->WAITING(1) if (time() - $start > 50);
# must search for children
$self->recurseFileSystem($start, $path."/".$file);

View file

@ -73,8 +73,9 @@ sub execute {
my $completion = $versionTag->commit({timeout => $self->getTTL});
if ($completion == 1) {
return $self->COMPLETE;
} elsif ($completion == 2) {
return $self->WAITING;
}
elsif ($completion == 2) {
return $self->WAITING(1);
}
return $self->ERROR;
}

View file

@ -94,7 +94,7 @@ sub execute {
}
if ((time() - $time) > $ttl) {
$sth->finish;
return $self->WAITING;
return $self->WAITING(1);
}
}

View file

@ -116,7 +116,7 @@ sub execute {
pause:
$instance->setScratch(DELETE_FILES_SCRATCH, Storable::freeze(\@files));
$instance->setScratch(PRUNE_DIRS_SCRATCH, Storable::freeze(\@dirs));
return $self->WAITING;
return $self->WAITING(1);
}
1;

View file

@ -91,7 +91,7 @@ sub execute {
}
if (time() - $start > $ttl) {
$pending->finish;
return $self->WAITING;
return $self->WAITING(1);
}
}
return $self->COMPLETE;

View file

@ -91,7 +91,7 @@ sub execute {
if (time() - $start > $ttl) {
$items->finish;
$log->('Ran out of time. Will have to expire the rest later.');
return $self->WAITING;
return $self->WAITING(1);
}
}
$log->info('No more EMS items to expire.');

View file

@ -112,7 +112,7 @@ sub execute {
# if there are urls left, we need to process again
if (scalar(@$assets) > 0) {
$instance->setScratch("syndicatedassets", JSON->new->encode($assets));
return $self->WAITING;
return $self->WAITING(1);
}
# if we've completed the list, clean up

View file

@ -119,7 +119,7 @@ sub execute {
$instance->setScratch('LowStockMessage', $message);
$instance->setScratch('LowStockLast', $counter);
$instance->setScratch('LowStockBelow', $belowThreshold);
return $self->WAITING;
return $self->WAITING(1);
}
$instance->deleteScratch('LowStockMessage');

View file

@ -115,7 +115,7 @@ sub execute {
$log->info("Ran out of time, will pick up with revision $version when we start again.");
$instance->setScratch("purgeOldAssetsLastRevisionDate", $version);
$sth->finish;
return $self->WAITING;
return $self->WAITING(1);
}
}
return $self->COMPLETE;

View file

@ -100,13 +100,13 @@ sub execute {
# give up if we're taking too long
if (time - $start > 120) {
$sth->finish;
return $self->WAITING;
return $self->WAITING(1);
}
}
# If there are more messages waiting to be purged, return WAITING
if ( $sth->rows >= $limit ) {
return $self->WAITING;
return $self->WAITING(1);
}
else {
return $self->COMPLETE;

View file

@ -194,7 +194,7 @@ sub execute {
# Update approval status
$instance->setScratch( "status", "notified" );
return $self->WAITING;
return $self->WAITING(60*20);
}
# Second and subsequent times, check status
# Tag is denied
@ -217,7 +217,7 @@ sub execute {
}
# If we haven't done anything, spin the wheel again
return $self->WAITING;
return $self->WAITING(60*60);
}
#----------------------------------------------------------------------------

View file

@ -198,7 +198,7 @@ sub execute {
if (time() - $time > 50) {
$eh->info("Oops. Ran out of time. Will continue building newsletters in a bit.");
$subscriptionResultSet->finish;
return $self->WAITING;
return $self->WAITING(1);
}
}
return $self->COMPLETE;

View file

@ -184,7 +184,7 @@ sub execute {
$link->unbind if defined $link;
$instance->setScratch('ldapSelectIndex', $index);
$sth->finish;
return $self->WAITING;
return $self->WAITING(1);
}
}

View file

@ -82,7 +82,8 @@ sub execute {
my $versionTag = shift;
my $session = $self->session;
my $urlOfSingleAsset = "";
$session->log->warn('a');
#By default, we'll make it so that things happen now.
my $time = $session->datetime->time();
@ -93,19 +94,25 @@ sub execute {
elsif ($self->get("type") eq "endTime") {
$time = $versionTag->get("endTime");
}
$session->log->warn('b');
#Turn start or end time into an epoch value
my $dt = WebGUI::DateTime->new($session,$time);
$session->log->warn('c');
#Get the current UTC time
my $now = WebGUI::DateTime->new($session,$session->datetime->time());
$session->log->warn('d');
#Workflow is complete if the time has passed.
if($now->epoch >= $dt->epoch) {
return $self->COMPLETE;
}
return $self->WAITING;
$session->log->warn('e');
$session->log->warn($dt->epoch - $now->epoch);
return $self->WAITING($dt->epoch - $now->epoch);
}

View file

@ -80,8 +80,10 @@ sub execute {
# do some work here, whatever this activity is supposed to do
# Workflow is finished
return $self->COMPLETE;
# Or needs to be run again to finish processing
#return $self->WAITING;
# Or we ran out of time, run again ASAP
return $self->WAITING(1);
# Or we're waiting on some external process to complete, wait an hour
#return $self->WAITING(60*60);
# Or encountered an error and cannot finish
#return $self->ERROR;
}