3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-10-01 17:16:39 +02:00

Update compiler_server.pl

This commit is contained in:
Pragmatic Software 2015-05-18 20:48:39 -07:00
parent 03baaeb81c
commit 06ee49d7ff

View File

@ -12,7 +12,7 @@ my $MONITOR_PORT = 3335;
my $SERIAL_PORT = 3333;
my $HEARTBEAT_PORT = 3336;
my $COMPILE_TIMEOUT = 7;
my $COMPILE_TIMEOUT = 10;
my $NOGRAPHIC = 1;
sub server_listen {
@ -34,7 +34,8 @@ sub server_listen {
sub vm_stop {
my $pid = shift @_;
return if not defined $pid;
kill 9, $pid;
print "killing vm $pid\n";
kill 'INT', $pid;
waitpid($pid, 0);
}
@ -46,7 +47,7 @@ sub vm_start {
}
if($pid == 0) {
my $command = "nice -n -20 qemu-system-x86_64 -M pc -net none -hda /home/compiler/compiler/compiler-savedvm.qcow2 -m 128 -monitor tcp:127.0.0.1:$MONITOR_PORT,server,nowait -serial tcp:127.0.0.1:$SERIAL_PORT,server,nowait -serial tcp:127.0.0.1:$HEARTBEAT_PORT,server -boot c -loadvm 1 -enable-kvm -no-kvm-irqchip" . ($NOGRAPHIC ? " -nographic" : "");
my $command = "qemu-system-x86_64 -M pc -net none -hda compiler-snap.qcow2 -m 512 -monitor tcp:127.0.0.1:$MONITOR_PORT,server,nowait -serial tcp:127.0.0.1:$SERIAL_PORT,server,nowait -serial tcp:127.0.0.1:$HEARTBEAT_PORT,server -boot c -enable-kvm -loadvm 1" . ($NOGRAPHIC ? " -nographic" : "");
my @command_list = split / /, $command;
exec(@command_list);
} else {
@ -84,7 +85,7 @@ sub execute {
my $pid = open(my $fh, '-|', "$cmdline 2>&1");
local $SIG{ALRM} = sub { print "Time out\n"; kill 9, $pid; die "Timed-out: $result\n"; };
local $SIG{ALRM} = sub { print "Time out\n"; kill 9, $pid; print "sent KILL to $pid\n"; die "Timed-out: $result\n"; };
alarm($COMPILE_TIMEOUT);
while(my $line = <$fh>) {
@ -200,7 +201,7 @@ sub compiler_server {
print "Attempting compile...\n";
alarm 0;
my ($ret, $result) = execute("./compiler_vm_client.pl \Q$nick\E \Q$channel\E -lang=\Q$lang\E \Q$code\E");
my ($ret, $result) = execute("./compiler_vm_client.pl \Q$lang\E \Q$nick\E \Q$channel\E \Q$code\E");
if(not defined $ret) {
#print "parent continued\n";
@ -250,7 +251,8 @@ sub compiler_server {
close $client;
next unless ($timed_out or $killed);
#next unless ($timed_out or $killed);
next unless $timed_out;
print "stopping vm $vm_pid\n";
vm_stop $vm_pid;