public virtual void Run(string accessKey, string folder, string logFilePath, string processType) { var arguments = "-d " + processType + " "; if ((folder != null) && (folder.Trim().Length != 0)) { arguments += "-f " + accessKey + " " + folder + " " + BinaryArguments; } else { arguments += accessKey + " " + BinaryArguments; } if (BinaryFileDoesNotExists) { DownloadBinary(); } Process?.Close(); if (processType.ToLower().Contains("start") && !string.IsNullOrEmpty(logFilePath) && LogFileExists(logFilePath)) { Log(logFilePath); } RunProcess(arguments, processType); }
/// <summary> /// Calls the script /// </summary> /// <param name="job">The current job</param> /// <returns>An ActionResult to determine the success and a list of errors</returns> public ActionResult ProcessJob(Job job) { _logger.Debug("Launched Script-Action"); ApplyPreSpecifiedTokens(job); var actionResult = Check(job.Profile, job.Accounts, CheckLevel.Job); if (!actionResult) { return(actionResult); } var scriptFile = job.Profile.Scripting.ScriptFile; _logger.Debug("Script-File: " + scriptFile); IProcess process = _processStarter.CreateProcess(scriptFile); var parameters = ComposeScriptParameters(job.Profile.Scripting.ParameterString, job.OutputFiles, job.TokenReplacer); process.StartInfo.Arguments = parameters; _logger.Debug("Script-Parameters: " + parameters); var scriptDir = _pathSafe.GetDirectoryName(scriptFile); if (scriptDir != null) { process.StartInfo.WorkingDirectory = scriptDir; } _logger.Debug("Script-Working Directory: " + scriptDir); process.EnableRaisingEvents = true; process.Exited += (sender, args) => process.Close(); try { _logger.Debug("Launching script..."); process.Start(); if (job.Profile.Scripting.WaitForScript) { _logger.Debug("Waiting for script to end"); process.WaitForExit(); _logger.Debug("Script execution ended"); } else { _logger.Debug("The script is executed in the background"); } return(new ActionResult()); } catch (Exception ex) { _logger.Error("Exception while running the script file \"" + scriptFile + "\"\r\n" + ex.Message); return(new ActionResult(ErrorCode.Script_GenericError)); } }
private async Task <bool> Close(IProcess process) { try { await process.Close(); return(await ProcessUtils.SpinWaitForExit(process, _waitForExitInSeconds)); } catch (Exception e) { Trace.TraceError($"Failed to close process {process.ExePath}, Exception: {e}"); return(false); } }
public virtual Task Close() { UnsubscribeFromExited(); return(_process.Close()); }
public Task Close() { _stopped = true; return(_process.Close()); }
private async Task <bool> Close(IProcess process) { await process.Close(); return(await ProcessUtils.SpinWaitForExit(process, _waitForExitInSeconds)); }
private async Task<bool> Close(IProcess process) { await process.Close(); return await ProcessUtils.SpinWaitForExit(process, _waitForExitInSeconds); }