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("spectrePort",32133);
|
||||
$session->config->set("spectreSubnets",["127.0.0.1/32"]);
|
||||
$session->config->set("spectreCryptoKey","123qwe");
|
||||
$session->config->set("workflowActivities", {
|
||||
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",
|
||||
|
|
|
|||
|
|
@ -292,12 +292,6 @@
|
|||
|
||||
"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
|
||||
# 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.
|
||||
|
||||
"port" : 32133,
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ sub _start {
|
|||
$self->debug("Reading workflow configs.");
|
||||
my $configs = WebGUI::Config->readAllConfigs($self->config->getWebguiRoot);
|
||||
foreach my $config (keys %{$configs}) {
|
||||
$kernel->yield("loadWorkflows", $config);
|
||||
$kernel->yield("loadWorkflows", $configs->{$config});
|
||||
}
|
||||
$kernel->yield("checkJobs");
|
||||
}
|
||||
|
|
@ -75,11 +75,12 @@ A hash reference containing a row of data from the WorkflowInstance table.
|
|||
|
||||
sub addJob {
|
||||
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
|
||||
my $sitename = $config->get("sitename");
|
||||
$self->{_jobs}{$job->{instanceId}} = {
|
||||
sitename=>$sitename->[0],
|
||||
instanceId=>$job->{instanceId},
|
||||
config=>$config,
|
||||
status=>"waiting",
|
||||
priority=>$job->{priority}
|
||||
};
|
||||
|
|
@ -208,8 +209,8 @@ sub getNextJob {
|
|||
|
||||
sub loadWorkflows {
|
||||
my ($kernel, $self, $config) = @_[KERNEL, OBJECT, ARG0];
|
||||
$self->debug("Loading workflows for ".$config.".");
|
||||
my $session = WebGUI::Session->open($self->config->getWebguiRoot, $config);
|
||||
$self->debug("Loading workflows for ".$config->getFilename.".");
|
||||
my $session = WebGUI::Session->open($config->getWebguiRoot, $config->getFilename);
|
||||
my $result = $session->db->read("select * from WorkflowInstance");
|
||||
while (my $data = $result->hashRef) {
|
||||
$kernel->yield("addJob", $config, $data);
|
||||
|
|
@ -258,15 +259,13 @@ sub runWorker {
|
|||
my ($kernel, $self, $job, $session) = @_[KERNEL, OBJECT, ARG0, SESSION];
|
||||
$self->debug("Preparing to run workflow instance ".$job->{instanceId}.".");
|
||||
POE::Component::Client::UserAgent->new;
|
||||
my $url = $job->{sitename}.'/'.$job->{gateway};
|
||||
$url =~ s/\/\//\//g;
|
||||
$url = "http://".$url."?op=spectre;instanceId=".$job->{instanceId};
|
||||
my $url = "http://".$job->{sitename}.'/';
|
||||
my $request = POST $url, [op=>"runWorkflow", instanceId=>$job->{instanceId}];
|
||||
my $cookie = $self->{_cookies}{$job->{sitename}};
|
||||
$request->header("Cookie","wgSession=".$cookie) if (defined $cookie);
|
||||
$request->header("User-Agent","Spectre");
|
||||
$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') });
|
||||
$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 {
|
||||
my $session = shift;
|
||||
$session->errorHandler->warn("A");
|
||||
$session->http->setMimeType("text/plain");
|
||||
$session->errorHandler->warn("b");
|
||||
return "error" unless (isInSubnet($session->env->get("REMOTE_ADDR"), $session->config->get("spectreSubnets")));
|
||||
$session->errorHandler->warn("c");
|
||||
my $instanceId = $session->form->param("instanceId");
|
||||
if ($instanceId) {
|
||||
$session->errorHandler->warn("d");
|
||||
my $instance = WebGUI::Workflow::Instance->new($session, $instanceId);
|
||||
if (defined $instance) {
|
||||
$session->errorHandler->warn("e");
|
||||
return $instance->run;
|
||||
}
|
||||
}
|
||||
$session->errorHandler->warn("f");
|
||||
return "error";
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue