Unverified Commit b17b846a authored by Francesc Guasch's avatar Francesc Guasch Committed by GitHub
Browse files

wip: use stored shutdown_timeout (#1540)

parent f0554a0f
......@@ -1924,6 +1924,7 @@ sub _upgrade_tables {
$self->_upgrade_table('domains','needs_restart','int not null default 0');
$self->_upgrade_table('domains','shutdown_disconnected','int not null default 0');
$self->_upgrade_table('domains','shutdown_timeout','int default null');
$self->_upgrade_table('domains','date_changed','timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP');
if ($self->_upgrade_table('domains','screenshot','MEDIUMBLOB')) {
......@@ -3863,7 +3864,7 @@ sub _cmd_shutdown {
my $uid = $request->args('uid');
my $name = $request->defined_arg('name');
my $id_domain = $request->defined_arg('id_domain');
my $timeout = ($request->args('timeout') or 60);
my $timeout = $request->defined_arg('timeout');
my $id_vm = $request->defined_arg('id_vm');
confess "ERROR: Missing id_domain or name" if !$id_domain && !$name;
......
......@@ -28,8 +28,8 @@ use Ravada::Booking;
use Ravada::Domain::Driver;
use Ravada::Utils;
our $TIMEOUT_SHUTDOWN = 20;
our $TIMEOUT_REBOOT = 20;
our $TIMEOUT_SHUTDOWN = 120;
our $TIMEOUT_REBOOT = 120;
our $CONNECTOR;
our $MIN_FREE_MEMORY = 1024*1024;
......@@ -2728,6 +2728,9 @@ sub _post_shutdown {
my %arg = @_;
my $timeout = delete $arg{timeout};
if (!defined $timeout) {
$timeout = ( $self->_data('shutdown_timeout') or $TIMEOUT_SHUTDOWN);
}
if ( $self->_vm->is_active ) {
$self->_remove_iptables();
......@@ -2755,7 +2758,7 @@ sub _post_shutdown {
}
}
if (defined $timeout && !$self->is_removed && $is_active) {
if (defined $timeout && $timeout && !$self->is_removed && $is_active) {
if ($timeout<2) {
sleep $timeout;
$is_active = $self->is_active;
......
......@@ -537,8 +537,6 @@ sub shutdown_domain {
my $args = _check_args('shutdown_domain', @_ );
$args->{timeout} = $TIMEOUT_SHUTDOWN if !exists $args->{timeout};
confess "ERROR: You must supply either id_domain or name ".Dumper($args)
if !$args->{id_domain} && !$args->{name};
......
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