added the starting foundation for spectre, much more still to be done
This commit is contained in:
parent
e4a4ecd342
commit
384f6cd392
5 changed files with 201 additions and 1 deletions
|
|
@ -14,6 +14,8 @@
|
|||
- Added template to Collaboration RSS feeds.
|
||||
- Added page.isContainer and page.isUtility template variables to Navigation
|
||||
templates.
|
||||
- Added Spectre, WebGUI's new background processing engine which manages
|
||||
things like scheduled tasks and workflow processing.
|
||||
|
||||
|
||||
6.7.7
|
||||
|
|
|
|||
|
|
@ -10,11 +10,13 @@
|
|||
|
||||
use lib "../../lib";
|
||||
use strict;
|
||||
use FileHandle;
|
||||
use Getopt::Long;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::SQL;
|
||||
use WebGUI::Asset;
|
||||
use WebGUI::Setting;
|
||||
use WebGUI::User;
|
||||
|
||||
my $toVersion = "6.8.0";
|
||||
my $configFile;
|
||||
|
|
@ -30,6 +32,8 @@ updateCollaboration();
|
|||
addPhotoField();
|
||||
addAvatarField();
|
||||
addEnableAvatarColumn();
|
||||
addSpectre();
|
||||
addWorkflow();
|
||||
finish();
|
||||
|
||||
#-------------------------------------------------
|
||||
|
|
@ -131,6 +135,74 @@ sub addEnableAvatarColumn {
|
|||
WebGUI::SQL->write('ALTER TABLE Collaboration ADD COLUMN avatarsEnabled int(11) NOT NULL DEFAULT 0');
|
||||
}
|
||||
|
||||
#-------------------------------------------------
|
||||
sub addSpectre {
|
||||
print "\tAdding Spectre\n" unless ($quiet);
|
||||
my $user = WebGUI::User->new("new","pbuser_________spectre");
|
||||
$user->username("Spectre");
|
||||
$user->addToGroups([3]);
|
||||
my $source = FileHandle->new("../../etc/spectre.conf.original","r");
|
||||
if (defined $source) {
|
||||
binmode($source);
|
||||
my $dest = FileHandle->new(">../../etc/spectre.conf");
|
||||
if (defined $dest) {
|
||||
binmode($dest);
|
||||
cp($source,$dest);
|
||||
$dest->close;
|
||||
}
|
||||
$source->close;
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------
|
||||
sub addWorkflow {
|
||||
print "\tAdding Workflow\n" unless ($quiet);
|
||||
WebGUI::SQL->write("create table WorkflowSchedule (
|
||||
taskId varchar(22) binary not null primary key,
|
||||
enabled int not null default 1
|
||||
minuteOfHour varchar(25),
|
||||
hourOfDay varchar(25),
|
||||
dayOfMonth varchar(25),
|
||||
monthOfYear varchar(25),
|
||||
dayOfWeek varchar(25),
|
||||
workflowId binary varchar(22) not null
|
||||
)");
|
||||
WebGUI::SQL->write("create table WofklowInstance (
|
||||
instanceId varchar(22) binary not null primary key,
|
||||
workflowId varchar(22) binary not null,
|
||||
currentActivityId varchar(22) binary not null,
|
||||
priority int
|
||||
)");
|
||||
WebGUI::SQL->write("create table WorkflowInstanceData (
|
||||
instanceId varchar(22) binary not null primary key,
|
||||
dataName varchar(35),
|
||||
className varchar(255),
|
||||
methodName varchar(255),
|
||||
parameters text
|
||||
)");
|
||||
WebGUI::SQL->write("create table Wofklow (
|
||||
workflowId varchar(22) binary not null primary key,
|
||||
title varchar(255),
|
||||
description text
|
||||
)");
|
||||
WebGUI::SQL->write("create table WorkflowActivity (
|
||||
activityId varchar(22) binary not null primary key,
|
||||
workflowId varchar(22) binary not null,
|
||||
title varchar(255),
|
||||
description text,
|
||||
previousActivityId varchar(22) binary not null,
|
||||
dateCreated bigint,
|
||||
className varchar(255)
|
||||
)");
|
||||
WebGUI::SQL->write("create table WorkflowActivityProperty (
|
||||
propertyId varchar(22) binary not null primary key,
|
||||
activityId varchar(22) binary not null,
|
||||
name varchar(255),
|
||||
value text
|
||||
)");
|
||||
}
|
||||
|
||||
|
||||
#--- DO NOT EDIT BELOW THIS LINE
|
||||
|
||||
#-------------------------------------------------
|
||||
|
|
|
|||
4
etc/spectre.conf.original
Normal file
4
etc/spectre.conf.original
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
# Define a port for Spectre to run on between 1024 and 65000.
|
||||
port = 32133
|
||||
|
||||
|
||||
|
|
@ -116,7 +116,7 @@ sub readAllConfigs {
|
|||
closedir(DIR);
|
||||
my %configs;
|
||||
foreach my $file (@files) {
|
||||
if ($file =~ /\.conf$/ && !($file =~ /^log.conf$/)) {
|
||||
if ($file =~ /\.conf$/ && !($file =~ /^log\.conf$/) && !($file =~ /^spectre\.conf$/)) {
|
||||
$configs{$file} = readConfig($webguiPath,$file);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
122
sbin/spectre.pl
Normal file
122
sbin/spectre.pl
Normal file
|
|
@ -0,0 +1,122 @@
|
|||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2005 Plain Black Corporation.
|
||||
#-------------------------------------------------------------------
|
||||
# Please read the legal notices (docs/legal.txt) and the license
|
||||
# (docs/license.txt) that came with this distribution before using
|
||||
# this software.
|
||||
#-------------------------------------------------------------------
|
||||
# http://www.plainblack.com info@plainblack.com
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use lib '../lib';
|
||||
use DateTime::Cron::Simple;
|
||||
use Getopt::Long;
|
||||
use POE qw(Session);
|
||||
use POE::Component::IKC::ClientLite;
|
||||
use POE::Component::IKC::Server;
|
||||
use POE::Component::IKC::Specifier;
|
||||
use WebGUI::Session;
|
||||
|
||||
$|=1; # disable output buffering
|
||||
my $help;
|
||||
my $shutdown;
|
||||
|
||||
GetOptions(
|
||||
'help'=>\$help,
|
||||
'shutdown'=>\$shutdown
|
||||
);
|
||||
|
||||
if ($help) {
|
||||
print <<STOP;
|
||||
S.P.E.C.T.R.E. is the Supervisor of Perplexing Event-handling Contraptions for
|
||||
Triggering Relentless Executions. It handles WebGUI's workflow, mail sending,
|
||||
search engine indexing, and other background processes.
|
||||
|
||||
Usage:
|
||||
|
||||
perl spectre.pl
|
||||
|
||||
|
||||
Options:
|
||||
|
||||
--shutdown Stops the running Spectre server.
|
||||
|
||||
STOP
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($shutdown) {
|
||||
my $remote = create_ikc_client(
|
||||
port=>32133,
|
||||
ip=>'127.0.0.1',
|
||||
name=>rand(100000),
|
||||
timeout=>10
|
||||
);
|
||||
die $POE::Component::IKC::ClientLite::error unless $remote;
|
||||
my $result = $remote->post('Spectre/shutdown');
|
||||
die $POE::Component::IKC::ClientLite::error unless defined $result;
|
||||
undef $remote;
|
||||
exit;
|
||||
}
|
||||
|
||||
fork and exit;
|
||||
|
||||
|
||||
POE::Component::IKC::Server->spawn(
|
||||
port => 32133,
|
||||
name => 'Spectre',
|
||||
);
|
||||
|
||||
POE::Session->create(
|
||||
inline_states => {
|
||||
_start => \&serviceStart,
|
||||
_stop => \&serviceStop,
|
||||
"shutdown" => \&serviceStop
|
||||
}
|
||||
);
|
||||
|
||||
POE::Kernel->run();
|
||||
exit 0;
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub serviceShutdown {
|
||||
my $kernel = $_[KERNEL];
|
||||
$kernel->yield("_stop");
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub serviceStart {
|
||||
print "Starting WebGUI Spectre...";
|
||||
my ( $kernel, $heap ) = @_[ KERNEL, HEAP ];
|
||||
my $serviceName = "Spectre";
|
||||
$kernel->alias_set($serviceName);
|
||||
$kernel->call( IKC => publish => $serviceName, ["shutdown"] );
|
||||
print "OK\n";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub serviceStop {
|
||||
my $kernel = $_[KERNEL];
|
||||
print "Stopping WebGUI Spectre...";
|
||||
if ($session{var}{userId}) {
|
||||
sessionClose();
|
||||
}
|
||||
print "OK\n";
|
||||
$kernel->stop;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub sessionOpen {
|
||||
WebGUI::Session::open("..",shift);
|
||||
WebGUI::Session::refreshUserInfo("pbuser_________spectre");
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub sessionClose {
|
||||
WebGUI::Session::close();
|
||||
}
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue