Exemplo n.º 1
0
def init():
    schedule_job(check_v2_config_job, config.get_v2_config_check_interval())
    schedule_job(traffic_job, config.get_traffic_job_interval())
    reset_day = config.get_reset_traffic_day()
    if reset_day <= 0:
        return
    now = datetime.now()
    next_day = now.date() + timedelta(days=1)
    next_day = datetime.combine(next_day, datetime.min.time())

    Timer((next_day - now).seconds + 5, reset_traffic_job).start()
Exemplo n.º 2
0
def init():
    schedule_job(check_v2_config_job, config.get_v2_config_check_interval())
    schedule_job(traffic_job, config.get_traffic_job_interval())
Exemplo n.º 3
0
def init():
    schedule.every().day.at("00:00").do(update_config)
    schedule_job(check_v2_config_job, config.get_v2_config_check_interval())
    schedule_job(traffic_job, config.get_traffic_job_interval())
Exemplo n.º 4
0
from util.schedule_util import scheduler
from v2ray.models import Inbound

__lock = threading.Lock()


@scheduler.scheduled_job(
    trigger=IntervalTrigger(seconds=config.get_v2_config_check_interval()))
def check_v2_config_job():
    with __lock:
        v2_config = v2_util.gen_v2_config_from_db()
        v2_util.write_v2_config(v2_config)


@scheduler.scheduled_job(
    trigger=IntervalTrigger(seconds=config.get_traffic_job_interval()))
def traffic_job():
    with __lock:
        if not v2_util.is_running():
            return
        traffics = v2_util.get_inbounds_traffic()
        if not traffics:
            return
        for traffic in traffics:
            upload = int(traffic.get('uplink', 0))
            download = int(traffic.get('downlink', 0))
            tag = traffic['tag']
            Inbound.query.filter_by(tag=tag).update({
                'up':
                Inbound.up + upload,
                'down':
Exemplo n.º 5
0
def init():
    schedule_job(check_v2_config_job, config.get_v2_config_check_interval())
    schedule_job(traffic_job, config.get_traffic_job_interval())
    schedule_job(check_v2ay_alive_job, 40)
    schedule_job(check_v2ray_version_job, 1800)