-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adjust checks for removal from existing_jobs dict + add more logging …
…+ only one scheduled job for a connector at a time (#739)
- Loading branch information
Showing
4 changed files
with
75 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import time | ||
|
||
import psutil | ||
from dask.distributed import WorkerPlugin | ||
from distributed import Worker | ||
|
||
from danswer.utils.logger import setup_logger | ||
|
||
logger = setup_logger() | ||
|
||
|
||
class ResourceLogger(WorkerPlugin): | ||
def __init__(self, log_interval: int = 60 * 5): | ||
self.log_interval = log_interval | ||
|
||
def setup(self, worker: Worker) -> None: | ||
"""This method will be called when the plugin is attached to a worker.""" | ||
self.worker = worker | ||
worker.loop.add_callback(self.log_resources) | ||
|
||
def log_resources(self) -> None: | ||
"""Periodically log CPU and memory usage.""" | ||
while True: | ||
cpu_percent = psutil.cpu_percent(interval=None) | ||
memory_available_gb = psutil.virtual_memory().available / (1024.0**3) | ||
# You can now log these values or send them to a monitoring service | ||
logger.debug( | ||
f"Worker {self.worker.address}: CPU usage {cpu_percent}%, Memory available {memory_available_gb}GB" | ||
) | ||
time.sleep(self.log_interval) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
b258ec1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
internal-search – ./
danswer.dev
www.danswer.dev
internal-search-danswer.vercel.app
internal-search.vercel.app
internal-search-git-main-danswer.vercel.app