public void Run()
 {
     destination.WriteEntry("Starting worker thread", EventLogEntryType.Information);
       InstrumentServerProcess process = new InstrumentServerProcess(destination);
       try {
     process.Run(executablePath, configPath, hostname, scriptsEnabled, scriptsDirectory);
       } catch (Exception ex) {
     destination.WriteEntry("Exception trying to start, " + ex.Message, EventLogEntryType.Error);
       }
       DateTime lastIter = DateTime.Now;
       DateTime lastExec = lastIter;
       while(doRun){
     Thread.Sleep(checkInterval);
     try {
       if(!process.IsRunning()){
     if( (DateTime.Now - lastExec) > TimeSpan.FromSeconds(Math.Pow(retryFallback, retries))){
       destination.WriteEntry("Attempting to start process", EventLogEntryType.Information);
       process.Run(executablePath, configPath, hostname, scriptsEnabled, scriptsDirectory);
       lastExec = DateTime.Now;
       retries = Math.Min(retries + 1, maxFallbackMult);
     }
       }
     } catch (Exception ex) {
       destination.WriteEntry("Exception trying to start, " + ex.Message, EventLogEntryType.Error);
       retries = Math.Min(retries + 1, maxFallbackMult);
     }
       }
       process.CleanupProcess();
       destination.WriteEntry("Worker thread ended", EventLogEntryType.Information);
 }
Exemplo n.º 2
0
        public void Run()
        {
            destination.WriteEntry("Starting worker thread", EventLogEntryType.Information);
            InstrumentServerProcess process = new InstrumentServerProcess(destination);

            try {
                process.Run(executablePath, configPath, hostname, scriptsEnabled, scriptsDirectory);
            } catch (Exception ex) {
                destination.WriteEntry("Exception trying to start, " + ex.Message, EventLogEntryType.Error);
            }
            DateTime lastIter = DateTime.Now;
            DateTime lastExec = lastIter;

            while (doRun)
            {
                Thread.Sleep(checkInterval);
                try {
                    if (!process.IsRunning())
                    {
                        if ((DateTime.Now - lastExec) > TimeSpan.FromSeconds(Math.Pow(retryFallback, retries)))
                        {
                            destination.WriteEntry("Attempting to start process", EventLogEntryType.Information);
                            process.Run(executablePath, configPath, hostname, scriptsEnabled, scriptsDirectory);
                            lastExec = DateTime.Now;
                            retries  = Math.Min(retries + 1, maxFallbackMult);
                        }
                    }
                } catch (Exception ex) {
                    destination.WriteEntry("Exception trying to start, " + ex.Message, EventLogEntryType.Error);
                    retries = Math.Min(retries + 1, maxFallbackMult);
                }
            }
            process.CleanupProcess();
            destination.WriteEntry("Worker thread ended", EventLogEntryType.Information);
        }