[TeamTalk 328]: [864] trunk/moast-bth/TeamTalkSimulator: Adding scripts for running bots across the queue
tk@edam.speech.cs.cmu.edu
tk at edam.speech.cs.cmu.edu
Fri Nov 2 07:47:07 EDT 2007
An HTML attachment was scrubbed...
URL: http://mailman.srv.cs.cmu.edu/pipermail/teamtalk-developers/attachments/20071102/a1841bf4/attachment.html
-------------- next part --------------
Added: trunk/moast-bth/TeamTalkSimulator/qSimulator.pl
===================================================================
--- trunk/moast-bth/TeamTalkSimulator/qSimulator.pl (rev 0)
+++ trunk/moast-bth/TeamTalkSimulator/qSimulator.pl 2007-11-02 11:47:06 UTC (rev 864)
@@ -0,0 +1,75 @@
+#!/usr/bin/perl
+
+use strict;
+use File::Spec;
+
+my $SCRIPT='runBotServer.sh';
+my $BOTSCRIPT=File::Spec->rel2abs('runBot.pl');
+unlink glob "$SCRIPT.*";
+
+my @robots = &get_bots('peerfile.txt');
+my $num_bots = scalar @robots;
+
+my $ticket = `qsub -q i686 -l nodes=$num_bots $SCRIPT`;
+chomp $ticket;
+print "ticket: $ticket$/";
+my $hoststring;
+do {
+ sleep 1;
+ open(STATUS, "qstat -f $ticket|");
+ $hoststring = (split(/ = /,(grep(/exec_host =/, <STATUS>))[0]))[1];
+} until ($hoststring);
+chomp $hoststring;
+my @hosts;
+foreach(split(/\+/, $hoststring)) {
+ s|/.*||;
+ push @hosts, $_;
+}
+die "Needed $num_bots" if(scalar @hosts != $num_bots);
+for(0..$#robots) {
+ ${$robots[$_]}{'host'} = $hosts[$_];
+}
+print &render_bots(@robots);
+
+foreach(@robots) {
+ my %robot = %$_;
+ my $cmd = "ssh $robot{'host'} $BOTSCRIPT -type=$robot{'type'} -name=$robot{'name'}";
+ print $cmd, $/;
+ system $cmd;
+}
+
+sub get_bots {
+ my $peerfile = shift;
+ open(PEERS, $peerfile) || die "Can't open peerfile: $peerfile";
+
+ my @robots;
+ while(<PEERS>) {
+ next if /^\#/ || !/\S/;
+ my @tokens = split;
+ my $name = $tokens[0];
+ next if $name eq 'optrader' || $name eq 'mapserver';
+ my %robot;
+ $robot{'name'} = $name;
+ my @addr = split(':', $tokens[1]);
+ $robot{'ip'} = $addr[0];
+ $robot{'port'} = $addr[1] if scalar @addr == 2;
+ $robot{'voice'} = $tokens[2];
+ $robot{'type'} = $tokens[3];
+ push @robots, \%robot;
+ }
+
+ return @robots;
+}
+
+sub render_bots {
+ my @robots = @_;
+ my $ret_string;
+ foreach(@robots) {
+ my %robot = %{$_};
+ for(keys %robot) {
+ $ret_string .= "$_: $robot{$_} ";
+ }
+ $ret_string .= $/;
+ }
+ return $ret_string;
+}
Property changes on: trunk/moast-bth/TeamTalkSimulator/qSimulator.pl
___________________________________________________________________
Name: svn:executable
+ *
Deleted: trunk/moast-bth/TeamTalkSimulator/qSimulator.sh
===================================================================
--- trunk/moast-bth/TeamTalkSimulator/qSimulator.sh 2007-11-02 02:19:14 UTC (rev 863)
+++ trunk/moast-bth/TeamTalkSimulator/qSimulator.sh 2007-11-02 11:47:06 UTC (rev 864)
@@ -1,5 +0,0 @@
-#!/bin/bash
-
-rm -f runSimulator.sh.*
-
-qsub runSimulator.sh
Added: trunk/moast-bth/TeamTalkSimulator/runBot.pl
===================================================================
--- trunk/moast-bth/TeamTalkSimulator/runBot.pl (rev 0)
+++ trunk/moast-bth/TeamTalkSimulator/runBot.pl 2007-11-02 11:47:06 UTC (rev 864)
@@ -0,0 +1,12 @@
+#!/usr/bin/perl
+
+use strict;
+
+my $MOAST = `pwd`.'/../moast';
+$ENV{'CONFIG_NML'} = "$MOAST/etc/moast.nml";
+$ENV{'CONFIG_INI'} = "$MOAST/etc/moast.ini";
+open(TMP, '>/tmp/tk.txt');
+print TMP join(' ', @ARGV), $/;
+close TMP;
+system("date >> /tmp/tk.txt");
+sleep 10;
Property changes on: trunk/moast-bth/TeamTalkSimulator/runBot.pl
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/moast-bth/TeamTalkSimulator/runBotServer.sh
===================================================================
--- trunk/moast-bth/TeamTalkSimulator/runBotServer.sh (rev 0)
+++ trunk/moast-bth/TeamTalkSimulator/runBotServer.sh 2007-11-02 11:47:06 UTC (rev 864)
@@ -0,0 +1,16 @@
+#!/bin/bash
+
+echo "This job was submitted by user: $PBS_O_LOGNAME"
+echo "This job was submitted to host: $PBS_O_HOST"
+echo "This job was submitted to queue: $PBS_O_QUEUE"
+echo "PBS working directory: $PBS_O_WORKDIR"
+echo "PBS job id: $PBS_JOBID"
+echo "PBS job name: $PBS_JOBNAME"
+echo "PBS environment: $PBS_ENVIRONMENT"
+echo " "
+echo "This script is running on `hostname` "
+
+MOAST=`pwd`/../moast
+export CONFIG_NML=${MOAST}/etc/moast.nml
+export CONFIG_INI=${MOAST}/etc/moast.ini
+sleep 10;
Property changes on: trunk/moast-bth/TeamTalkSimulator/runBotServer.sh
___________________________________________________________________
Name: svn:executable
+ *
More information about the TeamTalk-developers
mailing list