Allow self-hosted repo for server builder jars

This commit is contained in:
--unset 2024-05-05 10:12:10 -04:00
parent 88cee9903d
commit 5e778e9fd7
5 changed files with 11 additions and 8 deletions

View File

@ -18,8 +18,9 @@ logger = logging.getLogger(__name__)
class BigBucket:
def __init__(self, helper):
self.helper = helper
self.base_url = "https://jars.arcadiatech.org"
self.paper_base = "https://api.papermc.io"
self.base_url = str(
self.helper.get_setting("big_bucket_repo", "https://jars.arcadiatech.org")
).rstrip("/")
def _read_cache(self) -> dict:
cache_file = self.helper.big_bucket_cache
@ -29,7 +30,7 @@ class BigBucket:
cache = json.load(f)
except Exception as e:
logger.error(f"Unable to read serverjars.com cache file: {e}")
logger.error(f"Unable to read big_bucket cache file: {e}")
return cache

View File

@ -516,6 +516,7 @@ class Helpers:
"monitored_mounts": mounts,
"dir_size_poll_freq_minutes": 5,
"crafty_logs_delete_after_days": 0,
"big_bucket_repo": "https://jars.arcadiatech.org",
}
def get_all_settings(self):

View File

@ -686,15 +686,15 @@ class TasksManager:
)
def big_bucket_cache_refresher(self):
logger.info("Refreshing serverjars.com cache on start")
logger.info("Refreshing big bucket cache on start")
self.controller.big_bucket.refresh_cache()
logger.info("Scheduling Serverjars.com cache refresh service every 12 hours")
logger.info("Scheduling big bucket cache refresh service every 12 hours")
self.scheduler.add_job(
self.controller.big_bucket.refresh_cache,
"interval",
hours=12,
id="serverjars",
id="big_bucket",
)
def realtime(self):

View File

@ -31,6 +31,7 @@ config_json_schema = {
"monitored_mounts": {"type": "array"},
"dir_size_poll_freq_minutes": {"type": "integer"},
"crafty_logs_delete_after_days": {"type": "integer"},
"big_bucket_repo": {"type": "string"},
},
"additionalProperties": False,
"minProperties": 1,

View File

@ -146,8 +146,8 @@ class ServerHandler(BaseHandler):
return
page_data["server_api"] = False
if page_data["online"]:
page_data["server_api"] = self.helper.check_address_status(
"https://api.serverjars.com"
page_data["server_api"] = (
self.controller.big_bucket._check_bucket_alive()
)
page_data["server_types"] = self.controller.big_bucket.get_bucket_data()
page_data["js_server_types"] = json.dumps(