WebGUI::BackgroundProcess (used now by AssetExport)
This commit is contained in:
parent
20db0287b4
commit
79de38dc4a
11 changed files with 1309 additions and 43 deletions
|
|
@ -22,7 +22,7 @@ use Getopt::Long;
|
|||
use WebGUI::Session;
|
||||
use WebGUI::Storage;
|
||||
use WebGUI::Asset;
|
||||
|
||||
use List::Util qw(first);
|
||||
|
||||
my $toVersion = '7.10.2';
|
||||
my $quiet; # this line required
|
||||
|
|
@ -31,9 +31,52 @@ my $quiet; # this line required
|
|||
my $session = start(); # this line required
|
||||
|
||||
# upgrade functions go here
|
||||
addBackgroundProcessTable($session);
|
||||
installBackgroundProcessCleanup($session);
|
||||
|
||||
finish($session); # this line required
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Creates a new table for tracking background processes
|
||||
sub addBackgroundProcessTable {
|
||||
my $session = shift;
|
||||
my $db = $session->db;
|
||||
my $sth = $db->dbh->table_info('', '', 'BackgroundProcess', 'TABLE');
|
||||
return if ($sth->fetch);
|
||||
print "\tAdding BackgroundProcess table..." unless $quiet;
|
||||
my $sql = q{
|
||||
CREATE TABLE BackgroundProcess (
|
||||
id CHAR(22),
|
||||
groupId CHAR(22),
|
||||
status LONGTEXT,
|
||||
error TEXT,
|
||||
startTime BIGINT(20),
|
||||
endTime BIGINT(20),
|
||||
finished BOOLEAN DEFAULT FALSE,
|
||||
latch BOOLEAN DEFAULT FALSE,
|
||||
|
||||
PRIMARY KEY(id)
|
||||
);
|
||||
};
|
||||
$db->write($sql);
|
||||
print "DONE!\n" unless $quiet;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# install a workflow to clean up old background processes
|
||||
sub installBackgroundProcessCleanup {
|
||||
my $session = shift;
|
||||
print "\tInstalling Background Process Cleanup workflow..." unless $quiet;
|
||||
my $class = 'WebGUI::Workflow::Activity::RemoveOldBackgroundProcesses';
|
||||
$session->config->addToArray('workflowActivities/None', $class);
|
||||
my $wf = WebGUI::Workflow->new($session, 'pbworkflow000000000001');
|
||||
my $a = first { ref $_ eq $class } @{ $wf->getActivities };
|
||||
unless ($a) {
|
||||
$a = $wf->addActivity($class);
|
||||
$a->set(title => 'Remove Old Background Processes');
|
||||
};
|
||||
print "DONE!\n" unless $quiet;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Describe what our function does
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue