🚀 Auto-deploy: BotVPS atualizado em 21/04/2026 20:42:48
This commit is contained in:
20
tools_v2.py
20
tools_v2.py
@@ -7,6 +7,7 @@ from credential_manager import (
|
||||
gitea_api_url, gitea_token, supabase_url, supabase_anon_key,
|
||||
supabase_service_role_key
|
||||
)
|
||||
from deploy_manager import DeployManager
|
||||
|
||||
# ============================================================
|
||||
# UTILS
|
||||
@@ -138,6 +139,16 @@ class SystemTools:
|
||||
except Exception as e:
|
||||
return f"Erro ao listar {path}: {e}"
|
||||
|
||||
@staticmethod
|
||||
def pm2_status() -> str:
|
||||
"""Lista todos os processos gerenciados pelo PM2."""
|
||||
return run_bash("pm2 jlist")["output"]
|
||||
|
||||
@staticmethod
|
||||
def pm2_restart(name: str) -> str:
|
||||
"""Reinicia um processo no PM2 pelo nome ou ID."""
|
||||
return run_bash(f"pm2 restart {name}")["output"]
|
||||
|
||||
# ============================================================
|
||||
# WORKSPACE TOOLS (GWS CLI)
|
||||
# ============================================================
|
||||
@@ -148,6 +159,12 @@ class WorkspaceTools:
|
||||
"""Executa um comando gws completo (ex: gws-mr gmail +send ...)."""
|
||||
return run_bash(cmd)["output"]
|
||||
|
||||
@staticmethod
|
||||
def magic_deploy(git_url: str) -> str:
|
||||
"""Clona um repositório git e tenta realizar o deploy automático (Docker/Node/Python)."""
|
||||
dm = DeployManager()
|
||||
return dm.magic_deploy(git_url)
|
||||
|
||||
# ============================================================
|
||||
# REGISTRY
|
||||
# ============================================================
|
||||
@@ -172,6 +189,9 @@ TOOLS_V2 = {
|
||||
"read_file": {"desc": "Lê conteúdo de um arquivo", "func": SystemTools.read_file, "danger": "safe"},
|
||||
"write_file": {"desc": "Cria ou edita arquivo (caminho|conteúdo)", "func": SystemTools.write_file, "danger": "dangerous"},
|
||||
"ls": {"desc": "Lista arquivos num diretório", "func": SystemTools.list_dir, "danger": "safe"},
|
||||
"pm2_status": {"desc": "Status dos processos PM2", "func": SystemTools.pm2_status, "danger": "safe"},
|
||||
"pm2_restart": {"desc": "Reiniciar processo PM2", "func": SystemTools.pm2_restart, "danger": "medium"},
|
||||
"magic_deploy": {"desc": "Deploy automático via URL Git", "func": WorkspaceTools.magic_deploy, "danger": "dangerous"},
|
||||
|
||||
# Google Workspace
|
||||
"gws": {"desc": "Executa comando GWS CLI (ex: gws-mr drive files list)", "func": WorkspaceTools.gws_command, "danger": "medium"},
|
||||
|
||||
Reference in New Issue
Block a user