def add_job(self, job): if job.name in self.services: raise ValueError("Job %s is already a service", job.name) if job.name in self.jobs: # Jobs have a complex eq implementation that allows us to catch jobs that have not changed and thus # don't need to be updated during a reconfigure if job == self.jobs[job.name]: return log.info("re-adding job %s", job.name) # We're updating an existing job, we have to copy over run time information job.absorb_old_job(self.jobs[job.name]) if job.enabled: self.disable_job(job) self.enable_job(job) else: log.info("adding job %s", job.name) self.jobs[job.name] = job job.set_context(self.context) job.event_recorder.set_parent(self.event_recorder) self.setup_job_dir(job) job.listen(True, self.state_handler.store_state)
def add_job(self, job): if job.name in self.jobs: # Jobs have a complex eq implementation that allows us to catch jobs that have not changed and thus # don't need to be updated during a reconfigure if job == self.jobs[job.name]: return # We're updating an existing job, we have to copy over run time information job.absorb_old_job(self.jobs[job.name]) if job.enabled: self.disable_job(job) self.enable_job(job) self.jobs[job.name] = job job.set_context(self.context) self.setup_job_dir(job) job.state_callback = self.state_handler.store_state
run = job.restore_enable_run(e_data) except Exception, e: log.error("Cannot restore enabling runs for job %s: %s" % (job.name, str(e))) try: for d_data in data['disable_runs']: run = job.restore_disable_run(d_data) except Exception, e: log.error("Cannot restore disabling runs for job %s: %s" % (job.name, str(e))) for r_data in data['runs']: run = job.restore_main_run(r_data) if run.is_scheduled: reactor.callLater(sleep_time(run.run_time), self.mcp.run_job, run) job.set_context(self.mcp.context) next = job.next_to_finish() if job.enabled and next and next.is_queued: next.start() def delay_store(self): self.store_delayed = False self.store_state() def kill_child(self): if self.write_pid and os.waitpid(self.write_pid, os.WNOHANG)[0]: self.write_pid = None def store_state(self): """Stores the state of tron"""