Esempio n. 1
0
        private static Action Start(JobTaskFactoryContext context)
        {
            return () =>
            {
                context.Job.Extract(data =>
                {
                    Blob blob = context.Blobs.GetById(data.Blob);
                    BlobDeployment deployment = context.Execution.Deploy(blob);

                    if (deployment == null)
                    {
                        context.Execution.Progress.OnFailed("Blob deployment failed.");
                        return;
                    }

                    string executable = deployment.Find(data.Executable);
                    string workingDirectory = Path.GetDirectoryName(executable);

                    ProcessStartInfo info = new ProcessStartInfo
                    {
                        FileName = executable,
                        Arguments = data.Arguments,
                        WorkingDirectory = workingDirectory,
                        CreateNoWindow = true,
                        UseShellExecute = false
                    };

                    Process process = new Process
                    {
                        StartInfo = info,
                        EnableRaisingEvents = true
                    };

                    process.Exited += (sender, args) =>
                    {
                        context.Execution.Progress.OnCompleted();
                        process.Dispose();
                    };

                    context.Execution.Progress.OnScheduled();

                    try
                    {
                        if (process.Start() == false)
                        {
                            context.Execution.Progress.OnFailed("Process starting failed.");
                            return;
                        }
                    }
                    catch (Win32Exception ex)
                    {
                        context.Execution.Progress.OnFailed($"Process starting failed: {ex.Message}");
                        return;
                    }

                    context.Execution.Progress.OnStarted(process.Id);
                });
            };
        }
Esempio n. 2
0
        private static Action Start(JobTaskFactoryContext context)
        {
            return(() =>
            {
                context.Job.Extract(data =>
                {
                    Blob blob = context.Blobs.GetById(data.Blob);
                    BlobDeployment deployment = context.Execution.Deploy(blob);

                    if (deployment == null)
                    {
                        context.Execution.Progress.OnFailed("Blob deployment failed.");
                        return;
                    }

                    string executable = deployment.Find(data.Executable);
                    string workingDirectory = Path.GetDirectoryName(executable);

                    ProcessStartInfo info = new ProcessStartInfo
                    {
                        FileName = executable,
                        Arguments = data.Arguments,
                        WorkingDirectory = workingDirectory,
                        CreateNoWindow = true,
                        UseShellExecute = false
                    };

                    Process process = new Process
                    {
                        StartInfo = info,
                        EnableRaisingEvents = true
                    };

                    process.Exited += (sender, args) =>
                    {
                        context.Execution.Progress.OnCompleted();
                        process.Dispose();
                    };

                    context.Execution.Progress.OnScheduled();

                    try
                    {
                        if (process.Start() == false)
                        {
                            context.Execution.Progress.OnFailed("Process starting failed.");
                            return;
                        }
                    }
                    catch (Win32Exception ex)
                    {
                        context.Execution.Progress.OnFailed($"Process starting failed: {ex.Message}");
                        return;
                    }

                    context.Execution.Progress.OnStarted(process.Id);
                });
            });
        }
Esempio n. 3
0
        private static Action PublishStatistics(JobTaskFactoryContext context)
        {
            return(() =>
            {
                OnProcess(context.Execution, process =>
                {
                    context.Execution.Metrics.OnMemory(new JobMemoryUsage
                    {
                        NonpagedSystemMemorySize = process.NonpagedSystemMemorySize64
                    });

                    context.Execution.Metrics.OnProcessor(new JobProcessorUsage
                    {
                        TotalProcessorTime = process.TotalProcessorTime,
                        UserProcessorTime = process.UserProcessorTime
                    });
                });
            });
        }
Esempio n. 4
0
        private static Action PublishStatistics(JobTaskFactoryContext context)
        {
            return () =>
            {
                OnProcess(context.Execution, process =>
                {
                    context.Execution.Metrics.OnMemory(new JobMemoryUsage
                    {
                        NonpagedSystemMemorySize = process.NonpagedSystemMemorySize64
                    });

                    context.Execution.Metrics.OnProcessor(new JobProcessorUsage
                    {
                        TotalProcessorTime = process.TotalProcessorTime,
                        UserProcessorTime = process.UserProcessorTime
                    });
                });
            };
        }