From 8831a68e611407ced2aeb9a1a274fa8e1019b49b Mon Sep 17 00:00:00 2001 From: MuslemRahimi Date: Wed, 9 Oct 2024 19:27:58 +0200 Subject: [PATCH] update cron job schedule --- app/primary_cron_job.py | 20 ++++++++++++++++++++ app/secondary_cron_job.py | 5 ----- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/app/primary_cron_job.py b/app/primary_cron_job.py index ef3c074..885a0e5 100755 --- a/app/primary_cron_job.py +++ b/app/primary_cron_job.py @@ -576,6 +576,24 @@ def run_price_analysis(): ] run_command(command) +def run_ai_score(): + run_command(["python3", "cron_ai_score.py"]) + run_command(["python3", "cron_stockdeck.py"]) + run_command(["python3", "restart_json.py"]) + + # Define the directories for rsync + directories = ["stockdeck", "stock-screener", "ai-score"] + base_dir = "/root/backend/app/json" + remote_dir = f"root@{useast_ip_address}:{base_dir}" + + # Rsync commands in a loop + for directory in directories: + command = [ + "sudo", "rsync", "-avz", "-e", "ssh", + f"{base_dir}/{directory}", + f"{remote_dir}" + ] + run_command(command) # Create functions to run each schedule in a separate thread def run_threaded(job_func): @@ -590,6 +608,8 @@ schedule.every().day.at("03:00").do(run_threaded, run_dark_pool) schedule.every().day.at("05:00").do(run_threaded, run_options_gex).tag('options_gex_job') schedule.every().day.at("06:00").do(run_threaded, run_historical_price).tag('historical_job') +schedule.every().day.at("06:30").do(run_threaded, run_ai_score).tag('ai_score_job') + schedule.every().day.at("07:00").do(run_threaded, run_ta_rating).tag('ta_rating_job') schedule.every().day.at("09:00").do(run_threaded, run_hedge_fund).tag('hedge_fund_job') schedule.every().day.at("07:30").do(run_threaded, run_government_contract).tag('government_contract_job') diff --git a/app/secondary_cron_job.py b/app/secondary_cron_job.py index ecd450f..bf06e28 100755 --- a/app/secondary_cron_job.py +++ b/app/secondary_cron_job.py @@ -33,10 +33,6 @@ def run_restart_cache(): subprocess.run(["pm2", "restart","fastapi"]) subprocess.run(["pm2", "restart","fastify"]) -def run_stockdeck(): - week = datetime.today().weekday() - if week <= 5: - subprocess.run(["python3", "cron_stockdeck.py"]) def run_json_job(): # Run the asynchronous function inside an asyncio loop @@ -56,7 +52,6 @@ def run_threaded(job_func): schedule.every().day.at("06:30").do(run_threaded, run_pocketbase).tag('pocketbase_job') -schedule.every().day.at("13:30").do(run_threaded, run_stockdeck).tag('stockdeck_job') schedule.every().day.at("15:45").do(run_threaded, run_restart_cache) schedule.every(2).hours.do(run_threaded, run_json_job).tag('json_job') schedule.every(1).minutes.do(run_threaded, run_cron_price_alert).tag('price_alert_job')