示例#1
0
        public Uri InvokeTriggeredJob(string jobName, string arguments, string trigger)
        {
            TriggeredJob triggeredJob = GetJob(jobName);

            if (triggeredJob == null)
            {
                throw new JobNotFoundException($"Cannot find '{jobName}' triggered job");
            }

            triggeredJob.CommandArguments = arguments;

            if (IsShuttingdown)
            {
                throw new WebJobsStoppedException();
            }

            TriggeredJobRunner triggeredJobRunner =
                _triggeredJobRunners.GetOrAdd(
                    jobName,
                    _ => new TriggeredJobRunner(triggeredJob.Name, JobsBinariesPath, Environment, Settings, TraceFactory, Analytics));

            JobSettings jobSettings = triggeredJob.Settings;

            string runId = triggeredJobRunner.StartJobRun(triggeredJob, jobSettings, trigger, ReportTriggeredJobFinished);

            ClearJobListCache();

            return(BuildJobsUrl("{0}/history/{1}".FormatInvariant(jobName, runId)));
        }
示例#2
0
        public void InvokeTriggeredJob(string jobName, string arguments, string trigger)
        {
            TriggeredJob triggeredJob = GetJob(jobName);

            if (triggeredJob == null)
            {
                throw new JobNotFoundException();
            }

            triggeredJob.CommandArguments = arguments;

            if (IsShuttingdown)
            {
                throw new WebJobsStoppedException();
            }

            TriggeredJobRunner triggeredJobRunner =
                _triggeredJobRunners.GetOrAdd(
                    jobName,
                    _ => new TriggeredJobRunner(triggeredJob.Name, Environment, Settings, TraceFactory, Analytics));

            JobSettings jobSettings = triggeredJob.Settings;

            triggeredJobRunner.StartJobRun(triggeredJob, jobSettings, trigger, ReportTriggeredJobFinished);
            ClearJobListCache();
        }
示例#3
0
        private TriggeredJobRun BuildJobRun(DirectoryInfoBase jobRunDirectory, string jobName, bool isLatest)
        {
            if (!jobRunDirectory.Exists)
            {
                return(null);
            }

            string runId = jobRunDirectory.Name;
            string triggeredJobRunPath = jobRunDirectory.FullName;
            string statusFilePath      = Path.Combine(triggeredJobRunPath, TriggeredJobRunLogger.TriggeredStatusFile);

            var triggeredJobStatus = GetStatus <TriggeredJobStatus>(statusFilePath);

            if (triggeredJobStatus == null)
            {
                return(null);
            }

            if (triggeredJobStatus.Status == JobStatus.Running)
            {
                if (isLatest)
                {
                    // If it is the latest run, make sure it's actually running
                    string   triggeredJobDataPath    = Path.Combine(JobsDataPath, jobName);
                    LockFile triggeredJobRunLockFile = TriggeredJobRunner.BuildTriggeredJobRunnerLockFile(triggeredJobDataPath, TraceFactory);
                    if (!triggeredJobRunLockFile.IsHeld)
                    {
                        triggeredJobStatus.Status = JobStatus.Aborted;
                    }
                }
                else
                {
                    // If it's not latest run it cannot be running
                    triggeredJobStatus.Status = JobStatus.Aborted;
                }
            }

            return(new TriggeredJobRun()
            {
                Id = runId,
                JobName = jobName,
                Trigger = triggeredJobStatus.Trigger,
                Status = triggeredJobStatus.Status,
                StartTime = triggeredJobStatus.StartTime,
                EndTime = triggeredJobStatus.EndTime,
                Url = BuildJobsUrl("{0}/history/{1}".FormatInvariant(jobName, runId)),
                OutputUrl = BuildVfsLogUrl(triggeredJobRunPath, jobName, runId, TriggeredJobRunLogger.OutputLogFileName),
                ErrorUrl = BuildVfsLogUrl(triggeredJobRunPath, jobName, runId, TriggeredJobRunLogger.ErrorLogFileName)
            });
        }
示例#4
0
        public void InvokeTriggeredJob(string jobName)
        {
            TriggeredJob triggeredJob = GetJob(jobName);

            if (triggeredJob == null)
            {
                throw new JobNotFoundException();
            }

            TriggeredJobRunner triggeredJobRunner =
                _triggeredJobRunners.GetOrAdd(
                    jobName,
                    _ => new TriggeredJobRunner(triggeredJob.Name, Environment, Settings, TraceFactory, Analytics));

            triggeredJobRunner.StartJobRun(triggeredJob);
        }
示例#5
0
        public void InvokeTriggeredJob(string jobName)
        {
            TriggeredJob triggeredJob = GetJob(jobName);

            if (triggeredJob == null)
            {
                throw new JobNotFoundException();
            }

            if (IsShuttingdown)
            {
                throw new WebJobsStoppedException();
            }

            TriggeredJobRunner triggeredJobRunner =
                _triggeredJobRunners.GetOrAdd(
                    jobName,
                    _ => new TriggeredJobRunner(triggeredJob.Name, Environment, Settings, TraceFactory, Analytics));

            triggeredJobRunner.StartJobRun(triggeredJob, ReportTriggeredJobFinished);
        }