def get(): rq = get_rq() workers = _all_workers(rq) result = [] queues = {} for worker in workers: for queue in worker.queues: if queue.name not in queues: queues[queue.name] = { 'workers': 0, } queues[queue.name]['workers'] += 1 queues[queue.name]['count'] = queue.count for state in ['idle', 'busy', 'suspended']: state_key = '%s_workers' % state if state_key not in queues[queue.name]: queues[queue.name][state_key] = 0 state_key = '%s_workers' % worker.state if state_key not in queues[queue.name]: queues[queue.name][state_key] = 0 queues[queue.name][state_key] += 1 all = _all_queues(rq) for a in all: if a.name not in queues: queues[a.name] = { 'count': a.count, 'workers': 0 } for q in queues: data = {'name': q} data.update(queues[q]) data['deferred'] = _get_deferred_count(rq, q) result.append(data) return jsonify(result)
def get(): rq = get_rq() workers = all_workers(rq) result = [] for worker in workers: result.append(create_worker_obj(worker)) return jsonify(result)
def _get_queue(queue_name='default'): rqc = get_rq() queue = rqc.get_queue(name=queue_name) jobs = queue.get_jobs() result = [] for job in jobs: result.append(_create_queue_job_obj(job)) return jsonify(result)
def load_app(config): app.config['RQ_REDIS_URL'] = config['database'] rq = get_rq() rq.init_app(app) app.register_blueprint(jobs_bp) app.register_blueprint(workers_bp) app.register_blueprint(queues_bp) return app
def jobs_failed_get(): rqc = get_rq() return jsonify(_get_failed_jobs(rqc.connection))
# a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. import os from rsync_backup_cluster.rq import get_rq from rsync_backup_cluster.rsync import run_rsync from rsync_backup_cluster.utils import which rq = get_rq() DEFAULT_ALLOWED_RETURNCODES = [0] @rq.job def job_destination(destinations): for path, uid, gid, mode in destinations: if not os.path.isdir(path): os.mkdir(path) os.chown(path, uid, gid) os.chmod(path, mode) @rq.job def job_backup(job_data):