Auto-pull latest files from Git on restart command

This commit is contained in:
Dev Core
2026-10-29 00:56:25 +04:00
parent e170141376
commit dbe29e8717
4 changed files with 21 additions and 14 deletions
+10 -3
View File
@@ -98,13 +98,20 @@ class ProcessManager:
)
return success
def restart_task(self, name: str, force: bool = True) -> bool:
def restart_task(self, name: str, force: bool = True, pull_git: bool = True) -> bool:
with self._lock:
task = self._tasks.get(name)
if not task:
log_err(f"Задача '{name}' не найдена")
return False
# Синхронизация файлов из Git перед перезапуском
if pull_git and task.cfg.git.enabled:
log_info(f"[Git] Обновление файлов задачи '{name}' перед перезапуском...")
updated, msg = self.git_updater.sync_task_repo(task, manual=True, trigger_restart=False)
if updated:
log_info(f"[Git] {msg}")
task.stop(force=force)
task.restart_count += 1
success = task.start()
@@ -129,10 +136,10 @@ class ProcessManager:
if task.is_running():
self.stop_task(name, force=force)
def restart_all(self):
def restart_all(self, force: bool = True, pull_git: bool = True):
with self._lock:
for name in list(self._tasks.keys()):
self.restart_task(name)
self.restart_task(name, force=force, pull_git=pull_git)
def pull_git(self, task_name: Optional[str] = None, manual: bool = True) -> Dict[str, Tuple[bool, str]]:
"""Ручной запуск проверки и обновления из Git (для конкретной задачи или всех)"""