]> jspc29.x-matter.uni-frankfurt.de Git - daqdata.git/commitdiff
new startup script, must be used from beamtime sep03 on, mt
authorhadaq <hadaq>
Fri, 29 Aug 2003 07:47:14 +0000 (07:47 +0000)
committerhadaq <hadaq>
Fri, 29 Aug 2003 07:47:14 +0000 (07:47 +0000)
hadaq/start_agents_parallel_sep03 [new file with mode: 0644]

diff --git a/hadaq/start_agents_parallel_sep03 b/hadaq/start_agents_parallel_sep03
new file mode 100644 (file)
index 0000000..61c8781
--- /dev/null
@@ -0,0 +1,109 @@
+#!/usr/bin/perl -w
+
+use English;
+use Data::Dumper;
+use FileHandle;
+
+my $beamTime="sep03";
+
+my %system_cpu_map = ( 'rich0' => 'r2-24', 'rich1' => 'r2-28', 'rich2' => 'r2-27'  , 
+                      'trig'  => 'r2-35', 'shw'   => 'r2-29' , 'mdc0' => 'r2-8'   , 
+                      'mdc1'  => 'r2-32', 'tof1'  => 'E7_25' , 'tof2' =>  'E7_21'  ,
+                      'tof3'  => 'E7_41', 'tof4'  => 'E7_28', 'eb'    => 'hadeb03' );
+
+my %system_hwdir_map = ( 
+                        'trig'  => "hwtrig", 'tof'  => "" ,
+                        'mdc'   => "hwmdc",  'shw'  => "hwshow",
+                        'rich'  => "hwrich", 'eb'   => ""
+                       );
+
+my $fn = "hades.tcl";
+
+my $fh = new FileHandle("<$fn");
+my @text = <$fh>;
+$fh->close();
+
+my($cur_command);
+my(%Tasks);
+
+my @found = grep (/subSystem/,@text);
+my $found; 
+
+foreach (@found) {
+  next if( /^\s*#/ );
+  #print Dumper $_;
+  next if (!/^set\s+subSystem/);
+  $found = $_;
+}
+#print Dumper \$found;
+###    set subSystems { trig shw tof1 tof2 tof3 rich0 rich1 rich2 }
+my ($subSys) = $found =~ /\{\s*(.*)\s*\}/; 
+print "$subSys\n";
+
+my @subSys = split(/\s+/, $subSys);
+
+push(@subSys, "eb");
+print Dumper \@subSys;
+
+my %subSys;
+foreach my $cur_sys (@subSys) {
+  my $tmp = $cur_sys;
+  $tmp =~ s/\d//;
+  $subSys{$tmp} = 1;
+}
+
+#print Dumper \@subSys;
+
+#exit;
+
+my(@process_list);
+
+my($cur_system);
+foreach $cur_system (@subSys) {
+  print "$cur_system\n";
+  #next;
+  $child=fork();
+
+  if($child) {
+      #print "Parent PID: $PID\n";    
+      #print "Parent: child pid: $child\n";
+    push(@process_list, $child);
+  }
+  else { # fork childs 
+    print "child: pid: $PID\n";
+
+    my $cpu = $system_cpu_map{$cur_system};
+    my ($trunc_system) = $cur_system =~ /(.*)\d*/;
+    $trunc_system =~ s/\d+//;
+    #print "cpu: $cpu, trunc_system: $trunc_system\n";
+    my $path = "/hades/usr/hades/" . $beamTime . "/slow/" . $trunc_system;
+    my $path2 = "/hades/usr/hades/" . $beamTime . "/slow";
+
+    my $tmp = $system_hwdir_map{$trunc_system};
+    my $agent_path = "/hades/usr/hades/" . $beamTime . "/$trunc_system/$tmp";
+    my $user_name = "hades";
+
+    # exceptions
+    if($cur_system =~ /eb/) {
+       $user_name = "hadaq";
+       $agent_path = "/home/hadaq/" . $beamTime . "/eb/hadaq_tcl";
+    }
+
+    my($exec_command) = "rsh $cpu -l $user_name \"sh -c 'cd; . .bash_profile; cd $agent_path; echo \"DAQSETUP: \\\$DAQ_SETUP\"; type daq_agent; echo \"PWD:\"; pwd; ./daq_agent'\"";
+    print "exec: $exec_command\n";
+    system($exec_command);
+    print "finished pid:  $PID , cpu: $cpu, subsystem:  $cur_system, command: $exec_command\n";
+    exit();
+  }
+
+}
+
+
+my($cur_child_pid);
+foreach $cur_child_pid (@process_list) {
+  print "wait for child: $cur_child_pid\n";
+  waitpid($cur_child_pid,0);
+}
+print "ended process\n";
+
+