- fix: spectre
- fix: Spectre tries to delete the same workflow instance twice - Fixed part of the Spectre memory leak. See gotcha.txt for details.
This commit is contained in:
parent
ac953d2043
commit
35e0a63262
10 changed files with 93 additions and 50 deletions
|
|
@ -46,6 +46,7 @@ sub www_spectreTest {
|
|||
name=>rand(100000),
|
||||
timeout=>10
|
||||
);
|
||||
$remote->disconnect;
|
||||
# Can't perform this test until I get smarter. =)
|
||||
#return "spectre" unless $remote;
|
||||
#my $result = $remote->post_respond('admin/ping');
|
||||
|
|
|
|||
|
|
@ -65,23 +65,29 @@ sub create {
|
|||
my $instanceId = $session->db->setRow("WorkflowInstance","instanceId",{instanceId=>"new", runningSince=>time()});
|
||||
my $self = $class->new($session, $instanceId);
|
||||
$properties->{notifySpectre} = 1 unless ($properties->{notifySpectre} eq "0");
|
||||
$properties->{newlyCreated} = 1;
|
||||
$self->set($properties);
|
||||
return $self;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 delete ( )
|
||||
=head2 delete ( [ skipNotify ] )
|
||||
|
||||
Removes this instance.
|
||||
|
||||
=head3 skipNotify
|
||||
|
||||
A boolean, that if true will not notify Spectre of the delete.
|
||||
|
||||
=cut
|
||||
|
||||
sub delete {
|
||||
my $self = shift;
|
||||
my $skipNotify = shift;
|
||||
$self->session->db->write("delete from WorkflowInstanceScratch where instanceId=?",[$self->getId]);
|
||||
$self->session->db->deleteRow("WorkflowInstance","instanceId",$self->getId);
|
||||
WebGUI::Workflow::Spectre->new($self->session)->notify("workflow/deleteInstance",$self->getId);
|
||||
WebGUI::Workflow::Spectre->new($self->session)->notify("workflow/deleteInstance",$self->getId) unless ($skipNotify);
|
||||
undef $self;
|
||||
}
|
||||
|
||||
|
|
@ -254,7 +260,7 @@ sub run {
|
|||
}
|
||||
my $activity = $workflow->getNextActivity($self->get("currentActivityId"));
|
||||
unless (defined $activity) {
|
||||
$self->delete;
|
||||
$self->delete(1);
|
||||
return "done";
|
||||
}
|
||||
$self->session->errorHandler->info("Running workflow activity ".$activity->getId.", which is a ".(ref $activity).", for instance ".$self->getId.".");
|
||||
|
|
@ -373,7 +379,7 @@ sub set {
|
|||
$self->session->db->setRow("WorkflowInstance","instanceId",$self->{_data});
|
||||
if ($properties->{notifySpectre}) {
|
||||
my $spectre = WebGUI::Workflow::Spectre->new($self->session);
|
||||
$spectre->notify("workflow/deleteInstance",$self->getId);
|
||||
$spectre->notify("workflow/deleteInstance",$self->getId) unless ($properties->{newlyCreated});
|
||||
$spectre->notify("workflow/addInstance", {gateway=>$self->session->config->get("gateway"), sitename=>$self->session->config->get("sitename")->[0], instanceId=>$self->getId, priority=>$self->{_data}{priority}});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,21 +69,23 @@ A scalar, array reference, or hash reference of data to pass to Spectre.
|
|||
sub notify {
|
||||
my $self = shift;
|
||||
my $module = shift;
|
||||
my $params = shift;;
|
||||
my $params = shift;
|
||||
my ($config, $error) = $self->session->quick("config", "errorHandler");
|
||||
my $remote = create_ikc_client(
|
||||
port=>$self->session->config->get("spectrePort"),
|
||||
ip=>$self->session->config->get("spectreIp"),
|
||||
port=>$config->get("spectrePort"),
|
||||
ip=>$config->get("spectreIp"),
|
||||
name=>rand(100000),
|
||||
timeout=>10
|
||||
);
|
||||
if (defined $remote) {
|
||||
my $result = $remote->post($module, $params);
|
||||
unless (defined $result) {
|
||||
$self->session->errorHandler->warn("Couldn't send command to Spectre because ".$POE::Component::IKC::ClientLite::error);
|
||||
$error->warn("Couldn't send command to Spectre because ".$POE::Component::IKC::ClientLite::error);
|
||||
}
|
||||
$remote->disconnect;
|
||||
undef $remote;
|
||||
} else {
|
||||
$self->session->errorHandler->warn("Couldn't connect to Spectre because ".$POE::Component::IKC::ClientLite::error);
|
||||
$error->warn("Couldn't connect to Spectre because ".$POE::Component::IKC::ClientLite::error);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue