diff --git a/docs/changelog/6.x.x.txt b/docs/changelog/6.x.x.txt index 6de03ec0e..70ff1b2cb 100644 --- a/docs/changelog/6.x.x.txt +++ b/docs/changelog/6.x.x.txt @@ -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 diff --git a/docs/upgrades/upgrade_6.7.8-6.8.0.pl b/docs/upgrades/upgrade_6.7.8-6.8.0.pl index bf667e1ce..57ad42021 100644 --- a/docs/upgrades/upgrade_6.7.8-6.8.0.pl +++ b/docs/upgrades/upgrade_6.7.8-6.8.0.pl @@ -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 #------------------------------------------------- diff --git a/etc/spectre.conf.original b/etc/spectre.conf.original new file mode 100644 index 000000000..33539fb3c --- /dev/null +++ b/etc/spectre.conf.original @@ -0,0 +1,4 @@ +# Define a port for Spectre to run on between 1024 and 65000. +port = 32133 + + diff --git a/lib/WebGUI/Config.pm b/lib/WebGUI/Config.pm index 15a0dacfa..1c0cdb6a8 100644 --- a/lib/WebGUI/Config.pm +++ b/lib/WebGUI/Config.pm @@ -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); } } diff --git a/sbin/spectre.pl b/sbin/spectre.pl new file mode 100644 index 000000000..02054e0c0 --- /dev/null +++ b/sbin/spectre.pl @@ -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 <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(); +} + +