mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Fix bug where servers would not auto start.
This commit is contained in:
parent
3e3a068e48
commit
e2f4a33380
@ -12,6 +12,9 @@ import shutil
|
||||
import subprocess
|
||||
import zlib
|
||||
import html
|
||||
import apscheduler
|
||||
from apscheduler.schedulers.background import BackgroundScheduler
|
||||
import tzlocal
|
||||
|
||||
|
||||
from app.classes.shared.helpers import helper
|
||||
@ -141,7 +144,9 @@ class Server:
|
||||
logger.info("Scheduling server {} to start in {} seconds".format(self.name, delay))
|
||||
console.info("Scheduling server {} to start in {} seconds".format(self.name, delay))
|
||||
|
||||
schedule.every(delay).seconds.do(self.run_scheduled_server)
|
||||
self.server_scheduler = BackgroundScheduler(timezone=str(tzlocal.get_localzone()))
|
||||
self.server_scheduler.add_job(self.run_scheduled_server, 'interval', seconds=delay, id=str(self.server_id))
|
||||
self.server_scheduler.start()
|
||||
|
||||
def run_scheduled_server(self):
|
||||
console.info("Starting server ID: {} - {}".format(self.server_id, self.name))
|
||||
@ -149,7 +154,7 @@ class Server:
|
||||
self.run_threaded_server(None)
|
||||
|
||||
# remove the scheduled job since it's ran
|
||||
return schedule.CancelJob
|
||||
return self.server_scheduler.remove_job(str(self.server_id))
|
||||
|
||||
def run_threaded_server(self, user_id):
|
||||
# start the server
|
||||
|
@ -7,7 +7,6 @@ import logging
|
||||
import threading
|
||||
import asyncio
|
||||
import shutil
|
||||
from tzlocal import get_localzone
|
||||
import tzlocal
|
||||
|
||||
from pytz import HOUR, timezone
|
||||
|
Loading…
Reference in New Issue
Block a user