general cleanup
Some checks failed
Build and publish the docker image / build (push) Failing after 13s

Signed-off-by: ngn <ngn@ngn.tf>
This commit is contained in:
ngn
2025-01-21 04:58:44 +03:00
parent 7350155d2d
commit 62183646ae
18 changed files with 152 additions and 457 deletions

View File

@ -185,22 +185,22 @@ proc setRateLimit*(account: GuestAccount; api: Api; remaining, reset: int) =
account.apis[api] = RateLimit(remaining: remaining, reset: reset)
proc initAccountPool*(cfg: Config; path: string) =
proc initAccountPool*(cfg: Config) =
let path = cfg.accountsFile
enableLogging = cfg.enableDebug
let jsonlPath = if path.endsWith(".json"): (path & 'l') else: path
if fileExists(jsonlPath):
log "Parsing JSONL guest accounts file: ", jsonlPath
for line in jsonlPath.lines:
accountPool.add parseGuestAccount(line)
elif fileExists(path):
log "Parsing JSON guest accounts file: ", path
accountPool = parseGuestAccounts(path)
else:
echo "[accounts] ERROR: ", path, " not found. This file is required to authenticate API requests."
if !path.endswith(".jsonl"):
log "Accounts file should be formated with JSONL"
quit 1
if !fileExists(path):
log "Failed to access the accounts file (", path, ")"
quit 1
log "Parsing JSONL accounts file: ", path
for line in path.lines:
accountPool.add parseGuestAccount(line)
let accountsPrePurge = accountPool.len
#accountPool.keepItIf(not it.hasExpired)