keepalive: read master key from /app/data/.master_key (scheduler runs outside litellm's env)
This commit is contained in:
1 parent
acceb43995
commit
0d73c80562
1 file changed
+16
-2
+16
-2
@@ -10,9 +10,23 @@ success; prints + exits non-zero on failure so scheduler logs capture it.
|
||||
import json, os, urllib.request, urllib.error, sys
|
||||
|
||||
PORT = os.environ.get("PORT", "4000")
|
||||
KEY = os.environ.get("LITELLM_MASTER_KEY", "")
|
||||
|
||||
def master_key():
|
||||
"""The gateway's start.sh generates the master key into /app/data/.master_key
|
||||
and exports LITELLM_MASTER_KEY for the litellm process — scheduler tasks run
|
||||
in a separate process tree, so read the key file directly."""
|
||||
key = os.environ.get("LITELLM_MASTER_KEY", "")
|
||||
if key:
|
||||
return key
|
||||
try:
|
||||
with open("/app/data/.master_key") as f:
|
||||
return f.read().strip()
|
||||
except OSError:
|
||||
return ""
|
||||
|
||||
KEY = master_key()
|
||||
if not KEY:
|
||||
print("keepalive: LITELLM_MASTER_KEY not set", file=sys.stderr)
|
||||
print("keepalive: no master key (env or /app/data/.master_key)", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
fail = 0
|
||||
|
||||
Reference in new issue
Block a user