Commit 7e0c584d authored by Francesc Guasch's avatar Francesc Guasch
Browse files

start requests

parent d870956f
......@@ -270,6 +270,17 @@ sub _execute {
$request->status('done');
$request->error($@);
} elsif ($request->command eq 'start') {
$request->status('working');
my $name = $request->args('name');
eval {
my $domain = $self->search_domain($name);
die "Unknown domain '$name'\n" if !$domain;
$domain->start();
};
$request->status('done');
$request->error($@);
} else {
die "Unknown command ".$request->command;
}
......
......@@ -264,14 +264,12 @@ sub shutdown {
$req->error("Domain already down") if $req;
return;
}
warn "shut down";
$self->domain->shutdown();
$req->status("Shutting down") if $req;
for (0 .. $timeout) {
my $msg = "Domain ".$self->name." shutting down ($_ / $timeout)\n";
$req->error($msg) if $req;
warn $msg if $ENV{TERM};
last if !$self->is_active;
sleep 1;
......@@ -279,7 +277,6 @@ sub shutdown {
if ($self->is_active) {
my $msg = "Domaing wouldn't shut down, destroying\n";
$req->error($msg) if $req;
warn $msg if $ENV{TERM};
$self->domain->destroy();
}
$req->status("done") if $req;
......
......@@ -101,6 +101,28 @@ sub remove_domain {
}
=head2 start_domain
Requests to start a domain
my $req = Ravada::Request->start_domain( name => 'name' );
=cut
sub start_domain {
my $proto = shift;
my $class=ref($proto) || $proto;
my $name = shift;
$name = $name->name if ref($name) =~ /Domain/;
my %args = ( name => $name ) or confess "Missing domain name";
my $self = {};
bless($self,$class);
return $self->_new_request(command => 'start' , args => encode_json({ name => $name }));
}
sub _new_request {
my $self = shift;
......@@ -201,9 +223,14 @@ sub args {
sub AUTOLOAD {
my $self = shift;
my $name = $AUTOLOAD;
my $value = shift;
$name =~ s/.*://;
confess "Can't locate object method $name via package $self"
if !ref($self);
my $value = shift;
$name =~ tr/[a-z]/_/c;
confess "ERROR: Unknown field $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