Esempio n. 1
0
        public static Task Run(TaskType taskType)
        {
            var type        = GetTaskType(taskType);
            var pidFilename = PidFileHelper.GetPidFileName(type);

            using (var pidFile = new PidFileContext(pidFilename))
            {
                var task = (CliTask)ServiceLocator.Resolve(type);
                return(task.Run());
            }
        }
Esempio n. 2
0
        public void CreatePidFileForCurrentProcess(string filename)
        {
            if (PidFileHelper.IsTaskRunning(filename, out var pid))
            {
                throw new InvalidOperationException($"Process is already running (PID {pid}, PID file {filename})");
            }

            using (var currentProcess = Process.GetCurrentProcess())
            {
                File.WriteAllText(filename, currentProcess.Id.ToString());
            }
        }
Esempio n. 3
0
 public static PidFileContext For(Type taskType)
 {
     return(new PidFileContext(PidFileHelper.GetPidFileName(taskType)));
 }