def add_startup_jobs(self): sleep( 40 ) # To make sure that at least one server is running if the environment was started from quickstart scripts cluster_conf = self.config.main.cluster add_startup_jobs(cluster_conf.id, self.odb, self.startup_jobs, asbool(cluster_conf.stats_enabled))
def init_jobs(self): sleep( initial_sleep ) # To make sure that at least one server is running if the environment was started from quickstart scripts cluster_conf = self.config.main.cluster add_startup_jobs(cluster_conf.id, self.odb, self.startup_jobs, asbool(cluster_conf.stats_enabled)) # Actually start jobs now, including any added above if self._add_scheduler_jobs: add_scheduler_jobs(self.api, self.odb, self.config.main.cluster.id, spawn=False)
def run(self): try: # Add the statistics-related scheduler jobs to the ODB if self._add_startup_jobs: cluster_conf = self.config.main.cluster add_startup_jobs(cluster_conf.id, self.odb, self.startup_jobs, asbool(cluster_conf.stats_enabled)) # All other jobs if self._add_scheduler_jobs: add_scheduler_jobs(self.api, self.odb, self.config.main.cluster.id, spawn=False) _sleep = self.sleep _sleep_time = self.sleep_time with self.lock: for job in sorted(self.jobs): if job.max_repeats_reached: logger.info( 'Job `%s` already reached max runs count (%s UTC)', job.name, job.max_repeats_reached_at) else: self.spawn_job(job) # Ok, we're good now. self.ready = True logger.info('Scheduler started') while self.keep_running: _sleep(_sleep_time) if self.iter_cb: self.iter_cb(*self.iter_cb_args) except Exception, e: logger.warn(format_exc(e))