mirror of
https://github.com/Dictionarry-Hub/profilarr.git
synced 2026-01-22 10:51:02 +01:00
chore: remove watchdog
This commit is contained in:
@@ -3,4 +3,4 @@ WORKDIR /app
|
||||
COPY requirements.txt .
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
COPY . .
|
||||
CMD ["python", "run_dev.py"]
|
||||
CMD ["python", "run.py"]
|
||||
@@ -3,5 +3,4 @@ Flask-CORS==3.0.10
|
||||
PyYAML==5.4.1
|
||||
requests==2.26.0
|
||||
Werkzeug==2.0.1
|
||||
GitPython==3.1.24
|
||||
watchdog
|
||||
GitPython==3.1.24
|
||||
@@ -1,49 +0,0 @@
|
||||
import sys
|
||||
import time
|
||||
from watchdog.observers import Observer
|
||||
from watchdog.events import FileSystemEventHandler
|
||||
import subprocess
|
||||
import os
|
||||
|
||||
|
||||
class Reloader(FileSystemEventHandler):
|
||||
|
||||
def __init__(self):
|
||||
self.process = None
|
||||
self.last_restart = 0
|
||||
self.start_app()
|
||||
|
||||
def on_any_event(self, event):
|
||||
if event.src_path.endswith(
|
||||
'.py') and not event.src_path.endswith('run_dev.py'):
|
||||
current_time = time.time()
|
||||
if current_time - self.last_restart > 1: # Prevent rapid restarts
|
||||
print(f"Detected change in {event.src_path}, restarting...")
|
||||
self.restart_app()
|
||||
self.last_restart = current_time
|
||||
|
||||
def start_app(self):
|
||||
env = os.environ.copy()
|
||||
env['FLASK_ENV'] = 'development'
|
||||
self.process = subprocess.Popen([sys.executable, 'run.py'], env=env)
|
||||
|
||||
def restart_app(self):
|
||||
if self.process:
|
||||
self.process.terminate()
|
||||
self.process.wait()
|
||||
self.start_app()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
path = '.'
|
||||
event_handler = Reloader()
|
||||
observer = Observer()
|
||||
observer.schedule(event_handler, path, recursive=True)
|
||||
observer.start()
|
||||
|
||||
try:
|
||||
while True:
|
||||
time.sleep(1)
|
||||
except KeyboardInterrupt:
|
||||
observer.stop()
|
||||
observer.join()
|
||||
Reference in New Issue
Block a user