예제 #1
0
파일: agency.py 프로젝트: Signez/dradis2
import json
import redis
from dradis.common import status
from dradis.main import app
from dradis.models import db
from time import gmtime, strftime, time

db.init_app(app)
redis_instance = redis.StrictRedis()


def formatted_now():
    return strftime("%a, %d %b %Y %H:%M:%S +0000", gmtime())


def start_journalism():
    newsfeed = redis_instance.pubsub(ignore_subscribe_messages=True)

    newsfeed.subscribe('agency')

    for message in newsfeed.listen():
        liquidsoap_json_status = redis_instance.get('liquidsoap_json_status')
        liquidsoap_json_updated_at = redis_instance.get('liquidsoap_json_updated_at')
        current_status = status.system_status(liquidsoap_json_status, liquidsoap_json_updated_at)

        json_status = json.dumps(current_status)
        redis_instance.publish('broadcaster', json_status)

        redis_instance.set("agency_json_status", json_status)
        redis_instance.set('agency_updated_at', round(time() * 1000))
예제 #2
0
파일: tasks.py 프로젝트: Signez/dradis2
def celery_worker_init_db(**_):
    db.init_app(app)
예제 #3
0
파일: webserver.py 프로젝트: Signez/dradis2
from dradis.main import app, celery
from dradis.models import db

# Importing api routes
from dradis.api import *

db.init_app(app)

with app.app_context():
    db.create_all()

if __name__ == '__main__':
    app.run(
        **{
            "debug": True,
            "master": True,
            "threads": 4,
            "lazy": True,
            "lazy-apps": True,
            "log-master": True,
            "worker-reload-mercy": 2,
            "py-autoreload": 1
        })
예제 #4
0
def celery_worker_init_db(**_):
    db.init_app(app)