diff --git a/api/chalicelib/utils/pg_client.py b/api/chalicelib/utils/pg_client.py index c4149f49d..39a5e2e4b 100644 --- a/api/chalicelib/utils/pg_client.py +++ b/api/chalicelib/utils/pg_client.py @@ -20,6 +20,8 @@ PG_CONFIG = dict(_PG_CONFIG) if config("pg_timeout", cast=int, default=0) > 0: PG_CONFIG["options"] = f"-c statement_timeout={config('pg_timeout', cast=int) * 1000}" +logging.info(f">PG_POOL:{config('PG_POOL', cast=bool, default=None)}") + class ORThreadedConnectionPool(psycopg2.pool.ThreadedConnectionPool): def __init__(self, minconn, maxconn, *args, **kwargs): diff --git a/ee/api/app_crons.py b/ee/api/app_crons.py index 97f4b5406..55bc91619 100644 --- a/ee/api/app_crons.py +++ b/ee/api/app_crons.py @@ -1,28 +1,33 @@ print("============= CRONS =============") -import sys import asyncio +import sys from routers.crons import core_dynamic_crons +ACTIONS = { + "TELEMETRY": core_dynamic_crons.telemetry_cron, + "JOB": core_dynamic_crons.run_scheduled_jobs, + "REPORT": core_dynamic_crons.weekly_report +} + def default_action(action): async def _func(): print(f"{action} not found in crons-definitions") + print("possible actions:") + print(ACTIONS.keys()) return _func async def process(action): - await { - "TELEMETRY": core_dynamic_crons.telemetry_cron, - "JOB": core_dynamic_crons.run_scheduled_jobs, - "REPORT": core_dynamic_crons.weekly_report2 - }.get(action.upper(), default_action(action))() + await ACTIONS.get(action.upper(), default_action(action))() if __name__ == '__main__': if len(sys.argv) < 2 or len(sys.argv[1]) < 1: - print("please provide actions as argument") + print("please provide actions as argument\npossible actions:") + print(ACTIONS.keys()) else: print(f"action: {sys.argv[1]}") asyncio.run(process(sys.argv[1])) diff --git a/ee/api/routers/core_dynamic.py b/ee/api/routers/core_dynamic.py index e6675c4f3..a414aed05 100644 --- a/ee/api/routers/core_dynamic.py +++ b/ee/api/routers/core_dynamic.py @@ -6,9 +6,8 @@ from starlette.responses import RedirectResponse import schemas import schemas_ee -from chalicelib.core import integrations_manager from chalicelib.core import sessions -from chalicelib.core import tenants, users, metadata, projects, license +from chalicelib.core import tenants, users, projects, license from chalicelib.core import webhook from chalicelib.core.collaboration_slack import Slack from chalicelib.utils import SAML2_helper diff --git a/ee/api/routers/crons/core_dynamic_crons.py b/ee/api/routers/crons/core_dynamic_crons.py index 504300759..1d8320eb7 100644 --- a/ee/api/routers/crons/core_dynamic_crons.py +++ b/ee/api/routers/crons/core_dynamic_crons.py @@ -1,5 +1,6 @@ from chalicelib.core import telemetry, unlock -from chalicelib.core import weekly_report, jobs +from chalicelib.core import jobs +from chalicelib.core import weekly_report as weekly_report_script from decouple import config @@ -7,15 +8,14 @@ async def run_scheduled_jobs() -> None: jobs.execute_jobs() -async def weekly_report2() -> None: - weekly_report.cron() +async def weekly_report() -> None: + weekly_report_script.cron() async def telemetry_cron() -> None: telemetry.compute() -# @app.schedule(Cron('0/60', '*', '*', '*', '?', '*')) def unlock_cron() -> None: print("validating license") unlock.check() @@ -28,7 +28,7 @@ cron_jobs = [ SINGLE_CRONS = [{"func": telemetry_cron, "trigger": "cron", "day_of_week": "*"}, {"func": run_scheduled_jobs, "trigger": "interval", "seconds": 60, "misfire_grace_time": 20}, - {"func": weekly_report2, "trigger": "cron", "day_of_week": "mon", "hour": 5, + {"func": weekly_report, "trigger": "cron", "day_of_week": "mon", "hour": 5, "misfire_grace_time": 60 * 60}] if config("LOCAL_CRONS", default=False, cast=bool): diff --git a/ee/api/routers/ee.py b/ee/api/routers/ee.py index 9a79551b7..dc08ac569 100644 --- a/ee/api/routers/ee.py +++ b/ee/api/routers/ee.py @@ -1,7 +1,6 @@ from chalicelib.core import roles, traces from chalicelib.core import unlock from chalicelib.utils import assist_helper -from chalicelib.utils.TimeUTC import TimeUTC unlock.check()