Commit c3c4002a authored by Francesc Guasch's avatar Francesc Guasch
Browse files

[#122] Set killed requests done

parent dbc84569
......@@ -60,7 +60,6 @@ $Ravada::CAN_FORK=0 if $NOFORK;
our ($FH_DOWNLOAD, $DOWNLOAD_TOTAL);
my $RAVADA = Ravada->new( config => $FILE_CONFIG );
my $REMOTE_VIEWER;
###################################################################
#
......@@ -71,8 +70,11 @@ sub do_start {
my $old_error = ($@ or '');
my $cnt_error = 0;
my $ravada = Ravada->new( config => $FILE_CONFIG );
$ravada->clean_killed_requests();
for (;;) {
eval { $RAVADA->process_requests() };
eval { $ravada->process_requests() };
warn "$@\n" if $@ && (!$old_error || $old_error ne $@);
$old_error = ($@ or '');
if ( $@ && $cnt_error++ > 60 ) {
......@@ -145,7 +147,8 @@ sub import_domain {
print "User name : ";
my $user = <STDIN>;
chomp $user;
$RAVADA->import_domain(name => $name, vm => 'KVM', user => $user);
my $ravada = Ravada->new( config => $FILE_CONFIG );
$ravada->import_domain(name => $name, vm => 'KVM', user => $user);
}
#################################################################
......
......@@ -555,6 +555,25 @@ sub remove_volume {
}
=head2 clean_killed_requests
Before processing requests, old killed requests must be cleaned.
=cut
sub clean_killed_requests {
my $self = shift;
my $sth = $CONNECTOR->dbh->prepare("SELECT id FROM requests "
." WHERE status='working' "
);
$sth->execute;
while (my ($id) = $sth->fetchrow) {
my $req = Ravada::Request->open($id);
$req->status("done","Killed before completion");
}
}
=head2 process_requests
This is run in the ravada backend. It processes the commands requested by the fronted
......@@ -578,7 +597,8 @@ sub process_requests {
$sth->execute;
while (my ($id_request,$id_domain)= $sth->fetchrow) {
my $req = Ravada::Request->open($id_request);
next if $self->_domain_working($id_domain, $id_request);
next if $req->command !~ /shutdown/i
&& $self->_domain_working($id_domain, $id_request);
$self->_wait_pids_nohang();
warn "executing request ".$req->id." ".$req->status()." ".$req->command
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment