mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-20 02:49:49 +01:00
Factoids can now be run as background processes and have process-timeout override
This commit is contained in:
parent
a63a5308d5
commit
891a586409
@ -845,7 +845,17 @@ sub interpreter {
|
||||
return "";
|
||||
}
|
||||
|
||||
return $self->handle_action($stuff, $action);
|
||||
if ($self->{factoids}->get_data($channel, $keyword, 'background-process')) {
|
||||
my $timeout = $self->{factoids}->get_data($channel, $keyword, 'process-timeout') // $self->{pbot}->{registry}->get_value('processmanager', 'default_timeout');
|
||||
$self->{pbot}->{process_manager}->execute_process(
|
||||
$stuff,
|
||||
sub { $stuff->{result} = $self->handle_action($stuff, $action); },
|
||||
$timeout
|
||||
);
|
||||
return "";
|
||||
} else {
|
||||
return $self->handle_action($stuff, $action);
|
||||
}
|
||||
}
|
||||
|
||||
sub handle_action {
|
||||
|
@ -148,6 +148,12 @@ sub execute_process {
|
||||
|
||||
if (not exists $stuff->{commands}) { $stuff->{commands} = [$stuff->{command}]; }
|
||||
|
||||
# don't fork again if we're already a forked process
|
||||
if (exists $stuff->{pid}) {
|
||||
$subref->($stuff);
|
||||
return $stuff->{result};
|
||||
}
|
||||
|
||||
pipe(my $reader, my $writer);
|
||||
$stuff->{pid} = fork;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user