a little closer
This commit is contained in:
parent
3c1beb1de4
commit
3c1a42eeff
5 changed files with 14 additions and 22 deletions
|
|
@ -151,7 +151,6 @@ sub addWorkflow {
|
||||||
$session->config->set("spectreIp","127.0.0.1");
|
$session->config->set("spectreIp","127.0.0.1");
|
||||||
$session->config->set("spectrePort",32133);
|
$session->config->set("spectrePort",32133);
|
||||||
$session->config->set("spectreSubnets",["127.0.0.1/32"]);
|
$session->config->set("spectreSubnets",["127.0.0.1/32"]);
|
||||||
$session->config->set("spectreCryptoKey","123qwe");
|
|
||||||
$session->config->set("workflowActivities", {
|
$session->config->set("workflowActivities", {
|
||||||
None=>["WebGUI::Workflow::Activity::DecayKarma", "WebGUI::Workflow::Activity::TrashClipboard", "WebGUI::Workflow::Activity::CleanTempStorage",
|
None=>["WebGUI::Workflow::Activity::DecayKarma", "WebGUI::Workflow::Activity::TrashClipboard", "WebGUI::Workflow::Activity::CleanTempStorage",
|
||||||
"WebGUI::Workflow::Activity::CleanFileCache", "WebGUI::Workflow::Activity::CleanLoginHistory", "WebGUI::Workflow::Activity::ArchiveOldThreads",
|
"WebGUI::Workflow::Activity::CleanFileCache", "WebGUI::Workflow::Activity::CleanLoginHistory", "WebGUI::Workflow::Activity::ArchiveOldThreads",
|
||||||
|
|
|
||||||
|
|
@ -292,12 +292,6 @@
|
||||||
|
|
||||||
"spectrePort" : 32133,
|
"spectrePort" : 32133,
|
||||||
|
|
||||||
# Define the key that will be used to encrypt communcation
|
|
||||||
# between Spectre and WebGUI. Note that this must match the
|
|
||||||
# cryptoKey in the Spectre config file.
|
|
||||||
|
|
||||||
"spectreCryptoKey" : "123qwe",
|
|
||||||
|
|
||||||
# Define the workflow activities that are available in the editing
|
# Define the workflow activities that are available in the editing
|
||||||
# process and what object types they support.
|
# process and what object types they support.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,6 @@
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
# Define a key that will be used between Spectre and WebGUI to encrypt
|
|
||||||
# communication. Note that this key must match the "spectreCryptoKey"
|
|
||||||
# directive in your WebGUI config files.
|
|
||||||
|
|
||||||
"cryptoKey" : "123qwe",
|
|
||||||
|
|
||||||
# Define a port for Spectre to run on between 1024 and 65000.
|
# Define a port for Spectre to run on between 1024 and 65000.
|
||||||
|
|
||||||
"port" : 32133,
|
"port" : 32133,
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ sub _start {
|
||||||
$self->debug("Reading workflow configs.");
|
$self->debug("Reading workflow configs.");
|
||||||
my $configs = WebGUI::Config->readAllConfigs($self->config->getWebguiRoot);
|
my $configs = WebGUI::Config->readAllConfigs($self->config->getWebguiRoot);
|
||||||
foreach my $config (keys %{$configs}) {
|
foreach my $config (keys %{$configs}) {
|
||||||
$kernel->yield("loadWorkflows", $config);
|
$kernel->yield("loadWorkflows", $configs->{$config});
|
||||||
}
|
}
|
||||||
$kernel->yield("checkJobs");
|
$kernel->yield("checkJobs");
|
||||||
}
|
}
|
||||||
|
|
@ -75,11 +75,12 @@ A hash reference containing a row of data from the WorkflowInstance table.
|
||||||
|
|
||||||
sub addJob {
|
sub addJob {
|
||||||
my ($self, $config, $job) = @_[OBJECT, ARG0, ARG1];
|
my ($self, $config, $job) = @_[OBJECT, ARG0, ARG1];
|
||||||
$self->debug("Adding workflow instance ".$job->{instanceId}." from ".$config." to job queue at priority ".$job->{priority}.".");
|
$self->debug("Adding workflow instance ".$job->{instanceId}." from ".$config->getFilename." to job queue at priority ".$job->{priority}.".");
|
||||||
# job list
|
# job list
|
||||||
|
my $sitename = $config->get("sitename");
|
||||||
$self->{_jobs}{$job->{instanceId}} = {
|
$self->{_jobs}{$job->{instanceId}} = {
|
||||||
|
sitename=>$sitename->[0],
|
||||||
instanceId=>$job->{instanceId},
|
instanceId=>$job->{instanceId},
|
||||||
config=>$config,
|
|
||||||
status=>"waiting",
|
status=>"waiting",
|
||||||
priority=>$job->{priority}
|
priority=>$job->{priority}
|
||||||
};
|
};
|
||||||
|
|
@ -208,8 +209,8 @@ sub getNextJob {
|
||||||
|
|
||||||
sub loadWorkflows {
|
sub loadWorkflows {
|
||||||
my ($kernel, $self, $config) = @_[KERNEL, OBJECT, ARG0];
|
my ($kernel, $self, $config) = @_[KERNEL, OBJECT, ARG0];
|
||||||
$self->debug("Loading workflows for ".$config.".");
|
$self->debug("Loading workflows for ".$config->getFilename.".");
|
||||||
my $session = WebGUI::Session->open($self->config->getWebguiRoot, $config);
|
my $session = WebGUI::Session->open($config->getWebguiRoot, $config->getFilename);
|
||||||
my $result = $session->db->read("select * from WorkflowInstance");
|
my $result = $session->db->read("select * from WorkflowInstance");
|
||||||
while (my $data = $result->hashRef) {
|
while (my $data = $result->hashRef) {
|
||||||
$kernel->yield("addJob", $config, $data);
|
$kernel->yield("addJob", $config, $data);
|
||||||
|
|
@ -258,15 +259,13 @@ sub runWorker {
|
||||||
my ($kernel, $self, $job, $session) = @_[KERNEL, OBJECT, ARG0, SESSION];
|
my ($kernel, $self, $job, $session) = @_[KERNEL, OBJECT, ARG0, SESSION];
|
||||||
$self->debug("Preparing to run workflow instance ".$job->{instanceId}.".");
|
$self->debug("Preparing to run workflow instance ".$job->{instanceId}.".");
|
||||||
POE::Component::Client::UserAgent->new;
|
POE::Component::Client::UserAgent->new;
|
||||||
my $url = $job->{sitename}.'/'.$job->{gateway};
|
my $url = "http://".$job->{sitename}.'/';
|
||||||
$url =~ s/\/\//\//g;
|
|
||||||
$url = "http://".$url."?op=spectre;instanceId=".$job->{instanceId};
|
|
||||||
my $request = POST $url, [op=>"runWorkflow", instanceId=>$job->{instanceId}];
|
my $request = POST $url, [op=>"runWorkflow", instanceId=>$job->{instanceId}];
|
||||||
my $cookie = $self->{_cookies}{$job->{sitename}};
|
my $cookie = $self->{_cookies}{$job->{sitename}};
|
||||||
$request->header("Cookie","wgSession=".$cookie) if (defined $cookie);
|
$request->header("Cookie","wgSession=".$cookie) if (defined $cookie);
|
||||||
$request->header("User-Agent","Spectre");
|
$request->header("User-Agent","Spectre");
|
||||||
$request->header("X-JobId",$job->{instanceId});
|
$request->header("X-JobId",$job->{instanceId});
|
||||||
$self->debug("Posting workflow instance ".$job->{instanceId}.".");
|
$self->debug("Posting workflow instance ".$job->{instanceId}." to $url.");
|
||||||
$kernel->post( useragent => 'request', { request => $request, response => $session->postback('workerResponse') });
|
$kernel->post( useragent => 'request', { request => $request, response => $session->postback('workerResponse') });
|
||||||
$self->debug("Workflow instance ".$job->{instanceId}." posted.");
|
$self->debug("Workflow instance ".$job->{instanceId}." posted.");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -309,15 +309,21 @@ Checks to ensure the requestor is who we think it is, and then executes a workfl
|
||||||
|
|
||||||
sub www_runWorkflow {
|
sub www_runWorkflow {
|
||||||
my $session = shift;
|
my $session = shift;
|
||||||
|
$session->errorHandler->warn("A");
|
||||||
$session->http->setMimeType("text/plain");
|
$session->http->setMimeType("text/plain");
|
||||||
|
$session->errorHandler->warn("b");
|
||||||
return "error" unless (isInSubnet($session->env->get("REMOTE_ADDR"), $session->config->get("spectreSubnets")));
|
return "error" unless (isInSubnet($session->env->get("REMOTE_ADDR"), $session->config->get("spectreSubnets")));
|
||||||
|
$session->errorHandler->warn("c");
|
||||||
my $instanceId = $session->form->param("instanceId");
|
my $instanceId = $session->form->param("instanceId");
|
||||||
if ($instanceId) {
|
if ($instanceId) {
|
||||||
|
$session->errorHandler->warn("d");
|
||||||
my $instance = WebGUI::Workflow::Instance->new($session, $instanceId);
|
my $instance = WebGUI::Workflow::Instance->new($session, $instanceId);
|
||||||
if (defined $instance) {
|
if (defined $instance) {
|
||||||
|
$session->errorHandler->warn("e");
|
||||||
return $instance->run;
|
return $instance->run;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$session->errorHandler->warn("f");
|
||||||
return "error";
|
return "error";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue