diff --git a/app.py b/app.py index f7aba6c..4ad3101 100644 --- a/app.py +++ b/app.py @@ -188,11 +188,15 @@ app.register_blueprint(apiBP) if __name__ == '__main__': parser = argparse.ArgumentParser(description="Background Scheduler") - parser.add_argument('--interval', type=int, default=10, help="Interval in minutes") + (parser.add_argument + ('--servers-interval', type=int, default=10, help="Interval to check for idle servers. (in minutes)")) + (parser.add_argument + ('--modpacks-interval', type=int, default=48, help="Interval to check for modpack updates. (in hours)")) args = parser.parse_args() scheduler = BackgroundScheduler() - scheduler.add_job(generic_executor.scheduled_actions, 'interval', minutes=args.interval) + scheduler.add_job(generic_executor.scheduled_actions_short, 'interval', minutes=args.servers_interval) + scheduler.add_job(generic_executor.scheduled_actions_long, 'interval', hours=args.modpacks_interval) scheduler.start() run_simple('0.0.0.0', 3000, app, use_debugger=False, use_reloader=False) diff --git a/generic_executor.py b/generic_executor.py index 0cd4ef4..71e5712 100644 --- a/generic_executor.py +++ b/generic_executor.py @@ -328,9 +328,13 @@ def run_command(user: UserRecord, command: str, name: str) -> tuple[HTTPStatus, return HTTPStatus.INTERNAL_SERVER_ERROR, f"Error executing command: {command} || {str(e)}" -def scheduled_actions() -> None: +def scheduled_actions_short() -> None: mc_manager.check_servers_idle() +def scheduled_actions_long() -> None: + pass + + if __name__ == "__main__": pass