X-Git-Url: http://git.ieval.ro/?p=gruntmaster-daemon.git;a=blobdiff_plain;f=lib%2FGruntmaster%2FDaemon%2FFormat.pm;h=6d6bd8fd1fc8e8f1ce03a2866743fc632e4df222;hp=4a57d6a38b6757e99f6906645341efb21588095c;hb=34cc90c9aa31c1cad1fcef0684e940407426ad1d;hpb=614700357f0af54cdba3ac21b7420738bda2f3fe diff --git a/lib/Gruntmaster/Daemon/Format.pm b/lib/Gruntmaster/Daemon/Format.pm index 4a57d6a..6d6bd8f 100644 --- a/lib/Gruntmaster/Daemon/Format.pm +++ b/lib/Gruntmaster/Daemon/Format.pm @@ -14,9 +14,10 @@ use File::Slurp qw/read_file write_file/; use List::MoreUtils qw/natatime/; use Log::Log4perl qw/get_logger/; use String::ShellQuote qw/shell_quote/; +use Time::HiRes qw/time/; use Try::Tiny; -our $VERSION = '5999.000_004'; +our $VERSION = '5999.000_005'; our @EXPORT_OK = qw/prepare_files stopvms/; ################################################## @@ -29,8 +30,10 @@ sub runvm { my $cmd = $ENV{GRUNTMASTER_VM}; $cmd .= ' ' . $arg if $arg; get_logger->trace("Starting VM $name ($cmd)"); - $vm{$name} = Expect->spawn($cmd); + $vm{$name} = Expect->new; $vm{$name}->raw_pty(1); + $vm{$name}->log_stdout(0); + $vm{$name}->spawn($cmd); $vm{$name}->expect(5, '# ') or get_logger->logdie("Error while starting VM $name: ". $vm{$name}->error); } @@ -43,12 +46,13 @@ sub execlist_finish { my ($vm, $kill) = @_; if ($vm{$vm}) { - warn "Cannot kill VM" if $kill; + warn "Cannot kill VM\n" if $kill; $vm{$vm}->expect(5, '# '); } else { kill KILL => $pid{$vm} if $kill; waitpid $pid{$vm}, 0; } + write_file "time-stop-$vm", time; return if $kill; my $er = "exec-result-$vm"; @@ -62,11 +66,12 @@ sub execlist_finish { sub execlist { my ($vm, @args) = @_; + write_file "time-start-$vm", time; my $er = "exec-result-$vm"; if ($vm{$vm}) { my $cmd = ">$er " . shell_quote 'gruntmaster-exec', @args; get_logger->trace("Running in VM $vm: $cmd"); - $vm{$vm}->send($cmd); + $vm{$vm}->send($cmd, "\n"); } else { $pid{$vm} = fork // die "Cannot fork\n"; unless ($pid{$vm}) {