better cron job handling for spectre
This commit is contained in:
parent
10a1289bac
commit
5548da29a3
4 changed files with 133 additions and 31 deletions
|
|
@ -120,6 +120,7 @@ sub getOperations {
|
|||
'editCronJobSave' => 'WebGUI::Operation::Cron',
|
||||
'deleteCronJob' => 'WebGUI::Operation::Cron',
|
||||
'manageCron' => 'WebGUI::Operation::Cron',
|
||||
'runCronJob' => 'WebGUI::Operation::Cron',
|
||||
|
||||
'copyDatabaseLink' => 'WebGUI::Operation::DatabaseLink',
|
||||
'deleteDatabaseLink' => 'WebGUI::Operation::DatabaseLink',
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@ use WebGUI::AdminConsole;
|
|||
use WebGUI::HTMLForm;
|
||||
use WebGUI::International;
|
||||
use WebGUI::Workflow::Cron;
|
||||
use WebGUI::Workflow::Instance;
|
||||
use WebGUI::Utility;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
|
|
@ -239,4 +241,40 @@ sub www_manageCron {
|
|||
return $ac->render($output);
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_runCronJob ( )
|
||||
|
||||
Checks to ensure the requestor is who we think it is, and then executes a cron job and returns the results.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_runCronJob {
|
||||
my $session = shift;
|
||||
$session->http->setMimeType("text/plain");
|
||||
unless (isInSubnet($session->env->get("REMOTE_ADDR"), $session->config->get("spectreSubnets"))) {
|
||||
$session->errorHandler->security("make a Spectre cron job runner request, but we're only allowed to
|
||||
accept requests from ".join(",",@{$session->config->get("spectreSubnets")}).".");
|
||||
return "error";
|
||||
}
|
||||
my $taskId = $session->form->param("taskId");
|
||||
if ($taskId) {
|
||||
my $task = WebGUI::Workflow::Cron->new($session, $taskId);
|
||||
return "done" unless (defined $task);
|
||||
my $instance = WebGUI::Workflow::Instance->create($session, {
|
||||
workflowId=>$task->get("workflowId"),
|
||||
className=>$task->get("className"),
|
||||
methodName=>$task->get("methodName"),
|
||||
parameters=>$task->get("parameters"),
|
||||
priority=>$task->get("priority"),
|
||||
});
|
||||
$task->delete(1) if ($task->get("runOnce"));
|
||||
return "done";
|
||||
}
|
||||
$session->errorHandler->warn("No task ID passed to cron job runner.");
|
||||
return "error";
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
|
|
|
|||
|
|
@ -169,7 +169,7 @@ sub sendHeader {
|
|||
$self->session->request->status(301);
|
||||
} else {
|
||||
$self->session->request->content_type($self->{_http}{mimetype} || "text/html");
|
||||
$self->session->request->set_last_modified($self->{_http}{lastModified} || time());
|
||||
# $self->session->request->set_last_modified($self->{_http}{lastModified} || time());
|
||||
if ($self->session->setting->get("preventProxyCache")) {
|
||||
$self->session->request->headers_out->set(Expires => "-1d");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue