Fix check_server kicking off about given url
This commit is contained in:
parent
5743be54c0
commit
12f9a012f7
2 changed files with 13 additions and 3 deletions
|
@ -489,11 +489,14 @@ class Ollama(commands.Cog):
|
||||||
"""Returns the next server key."""
|
"""Returns the next server key."""
|
||||||
if increment:
|
if increment:
|
||||||
self.last_server += 1
|
self.last_server += 1
|
||||||
return SERVER_KEYS[self.last_server % len(SERVER_KEYS)]
|
s = SERVER_KEYS[self.last_server % len(SERVER_KEYS)]
|
||||||
|
self.log.info("Next server is %s", s)
|
||||||
|
return s
|
||||||
|
|
||||||
async def check_server(self, url: str) -> bool:
|
async def check_server(self, url: str) -> bool:
|
||||||
"""Checks that a server is online and responding."""
|
"""Checks that a server is online and responding."""
|
||||||
|
if url in SERVER_KEYS:
|
||||||
|
url = CONFIG["ollama"][url]["base_url"]
|
||||||
async with aiohttp.ClientSession(timeout=aiohttp.ClientTimeout(10)) as session:
|
async with aiohttp.ClientSession(timeout=aiohttp.ClientTimeout(10)) as session:
|
||||||
self.log.debug("Checking if %r is online.", url)
|
self.log.debug("Checking if %r is online.", url)
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import asyncio
|
import asyncio
|
||||||
import datetime
|
import datetime
|
||||||
import logging
|
import logging
|
||||||
|
import shutil
|
||||||
import sys
|
import sys
|
||||||
import traceback
|
import traceback
|
||||||
import typing
|
import typing
|
||||||
|
@ -15,6 +16,7 @@ from logging import FileHandler
|
||||||
import discord
|
import discord
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
from rich.logging import RichHandler
|
from rich.logging import RichHandler
|
||||||
|
from rich.console import Console
|
||||||
from conf import CONFIG
|
from conf import CONFIG
|
||||||
|
|
||||||
|
|
||||||
|
@ -65,6 +67,7 @@ class KumaThread(KillableThread):
|
||||||
|
|
||||||
log = logging.getLogger("jimmy")
|
log = logging.getLogger("jimmy")
|
||||||
CONFIG.setdefault("logging", {})
|
CONFIG.setdefault("logging", {})
|
||||||
|
cols, lns = shutil.get_terminal_size((120, 48))
|
||||||
|
|
||||||
logging.basicConfig(
|
logging.basicConfig(
|
||||||
format="%(asctime)s %(levelname)s %(name)s: %(message)s",
|
format="%(asctime)s %(levelname)s %(name)s: %(message)s",
|
||||||
|
@ -75,7 +78,11 @@ logging.basicConfig(
|
||||||
level=CONFIG["logging"].get("level", "INFO"),
|
level=CONFIG["logging"].get("level", "INFO"),
|
||||||
show_time=False,
|
show_time=False,
|
||||||
show_path=False,
|
show_path=False,
|
||||||
markup=True
|
markup=True,
|
||||||
|
console=Console(
|
||||||
|
width=cols,
|
||||||
|
height=lns
|
||||||
|
)
|
||||||
),
|
),
|
||||||
FileHandler(
|
FileHandler(
|
||||||
filename=CONFIG["logging"].get("file", "jimmy.log"),
|
filename=CONFIG["logging"].get("file", "jimmy.log"),
|
||||||
|
|
Loading…
Reference in a new issue