+void AliOnlineReco::StartAliEve(mIntInt_i& mi)
+{
+ // Start alieve to process run given my the run-pid entry.
+
+ Int_t run = mi->first;
+
+ if (mi->second == 0)
+ {
+ pid_t pid = fork();
+ if (pid == -1)
+ {
+ perror("DoStart -- Fork failed");
+ return;
+ }
+
+ if (pid)
+ {
+ mi->second = pid;
+ fRunList->RemoveEntry(run);
+ fRunList->AddEntrySort(TString::Format("%-20d -- RUNNING", run), run);
+ fRunList->Layout();
+ }
+ else
+ {
+ gCINTMutex = 0;
+
+ struct sigaction sac;
+ sac.sa_handler = 0;
+ sigemptyset(&sac.sa_mask);
+ sac.sa_flags = 0;
+ sigaction(SIGCHLD, &sac, 0);
+
+ int s;
+ if (fTestMode)
+ {
+ s = execlp("alitestproc", "alitestproc", TString::Format("%d", run).Data(), (char*) 0);
+ }
+ else
+ {
+ Int_t procPID = gSystem->GetPid();
+ TString logFile = Form("%s/reco/log/run%d_%d.log",
+ gSystem->Getenv("ONLINERECO_BASE_DIR"),
+ run,
+ (Int_t)procPID);
+ Info("DoStart","Reconstruction log will be written to %s",logFile.Data());
+ gSystem->RedirectOutput(logFile.Data());
+
+ gSystem->cd(Form("%s/reco",gSystem->Getenv("ONLINERECO_BASE_DIR")));
+
+ TString gdcs;
+ if (RetrieveGRP(run,gdcs) <= 0 || gdcs.IsNull())
+ gSystem->Exit(1);
+
+ gSystem->Setenv("DATE_RUN_NUMBER", Form("%d", run));
+ // Setting CDB
+// AliCDBManager * man = AliCDBManager::Instance();
+// man->SetDefaultStorage("local:///local/cdb");
+// man->SetSpecificStorage("GRP/GRP/Data",
+// Form("local://%s",gSystem->pwd()));
+// man->SetSpecificStorage("GRP/CTP/Config",
+// Form("local://%s",gSystem->pwd()));
+// man->SetSpecificStorage("ACORDE/Align/Data",
+// "local://$ALICE_ROOT/OCDB");
+
+ gSystem->mkdir(Form("run%d_%d", run, (Int_t)procPID));
+ gSystem->cd(Form("run%d_%d", run, (Int_t)procPID));
+
+ TString recMacroPath(gSystem->Getenv("ONLINERECO_MACRO"));
+ if (recMacroPath.IsNull()) {
+ recMacroPath = "$ALICE_ROOT/MONITOR/rec.C";
+ }
+
+ s = execlp("alieve",
+ "alieve",
+ "-q",
+ Form("%s(\"mem://@*:\")", gSystem->ExpandPathName(recMacroPath.Data())),
+ (char*) 0);
+
+ gSystem->Exec(Form("rm -rf %s/reco/run%d_%d",gSystem->Getenv("ONLINERECO_BASE_DIR"),run,(Int_t)procPID));
+ }
+
+ if (s == -1)
+ {
+ perror("execlp failed - this will not end well");
+ gSystem->Exit(1);
+ }
+ }
+ }
+ else
+ {
+ Error("DoStart", "Process already running.");
+ }
+}
+
+void AliOnlineReco::KillPid(Int_t pid)
+{
+ // Terminate process given by pid.
+
+ // Send terminate signal to process ...
+
+ if (fTestMode)
+ {
+ kill(pid, SIGTERM);
+ }
+ else
+ {
+ // alieve will auto-destruct on SIGUSR1
+ kill(pid, SIGUSR1);
+ }
+}
+
+void AliOnlineReco::StartAutoRunTimer(Int_t run)
+{
+ // Start timer for given run.
+ // If an auto-started run is already active, this call is ignored.
+ // If timer is already active, it is restarted.
+
+ if (fAutoRunRunning)
+ return;
+
+ fAutoRunTimer->Reset();
+ fAutoRunTimer->TurnOn();
+ fAutoRunScheduled = run;
+
+ Info("StartAutoRunTimer", "Scheduling run %d for auto-display.", run);
+}
+
+void AliOnlineReco::StopAutoRunTimer()
+{
+ // Stop auto-run timer.
+
+ fAutoRunTimer->TurnOff();
+ fAutoRunScheduled = 0;
+}
+
+void AliOnlineReco::AutoRunTimerTimeout()
+{
+ // Slot called on auto-timer timeout.
+
+ Int_t run = fAutoRunScheduled;
+
+ StopAutoRunTimer();
+
+ mIntInt_i i = fRun2PidMap.find(run);
+
+ if (i == fRun2PidMap.end())
+ {
+ Warning("AutoRunTimerTimeout", "run no longer active.");
+ return;
+ }
+
+ Info("AutoRunTimerTimeout", "Starting display for run %d.", run);
+
+ StartAliEve(i);
+ fAutoRunRunning = run;
+}
+