mirror of
https://github.com/hubHarmony/servii-backend.git
synced 2024-11-17 21:40:31 +00:00
[+] Added a longer scheduler.
Soon will be implemented a modpack update check.
This commit is contained in:
parent
bf49e5c038
commit
29b42be411
8
app.py
8
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)
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user