Inteligentny runner do rozwiązywania problemów infrastrukturalnych
Project description
Infrash
Inteligentny runner do rozwiązywania problemów infrastrukturalnych, zarządzania repozytoriami i automatyzacji wdrożeń.
Opis
Infrash to narzędzie wiersza poleceń zaprojektowane do automatyzacji i rozwiązywania problemów związanych z infrastrukturą IT. Umożliwia zarządzanie repozytoriami, instalację zależności, diagnostykę i naprawę problemów oraz wdrażanie aplikacji na różnych systemach operacyjnych.
Architektura systemu
Ogólna architektura
graph TB
User([Użytkownik]) --> CLI[CLI]
CLI --> Runner[Runner]
CLI --> Diagnostics[Diagnostics]
CLI --> Orchestrator[Orchestrator]
Runner --> GitManager[Git Manager]
Runner --> DependencyManager[Dependency Manager]
Runner --> ProcessManager[Process Manager]
Diagnostics --> NetworkDiagnostics[Network Diagnostics]
Diagnostics --> SystemDiagnostics[System Diagnostics]
Diagnostics --> SolutionsDB[(Solutions Database)]
Orchestrator --> ProjectDetector[Project Detector]
Orchestrator --> NetworkManager[Network Manager]
Orchestrator --> DiagnosticsEngine[Diagnostics Engine]
Orchestrator --> RemoteManager[Remote Manager]
GitManager --> Git[(Git Repositories)]
DependencyManager --> PackageManagers[(Package Managers)]
ProcessManager --> RunningApps[(Running Applications)]
NetworkManager --> RemoteHosts[(Remote Hosts)]
style CLI fill:#f9f,stroke:#333,stroke-width:2px,color:#333
style Runner fill:#bbf,stroke:#333,stroke-width:2px,color:#333
style Diagnostics fill:#bfb,stroke:#333,stroke-width:2px,color:#333
style Orchestrator fill:#fbf,stroke:#333,stroke-width:2px,color:#333
Przepływ danych w systemie
sequenceDiagram
participant User as Użytkownik
participant CLI
participant Orchestrator
participant ProjectDetector
participant DependencyManager
participant NetworkManager
participant DiagnosticsEngine
participant RemoteManager
User->>CLI: Uruchom komendę
CLI->>Orchestrator: Przetwórz projekt
Orchestrator->>Orchestrator: Sklonuj repozytorium
Orchestrator->>ProjectDetector: Wykryj typ projektu
ProjectDetector-->>Orchestrator: Zwróć typy projektu
Orchestrator->>DependencyManager: Zainstaluj zależności
DependencyManager-->>Orchestrator: Status instalacji
alt Lokalne uruchomienie
Orchestrator->>Orchestrator: Uruchom aplikację
else Zdalne wdrożenie
Orchestrator->>RemoteManager: Wdrożenie zdalne
RemoteManager->>RemoteHost: Połącz z hostem
RemoteHost-->>RemoteManager: Status połączenia
RemoteManager->>RemoteHost: Skonfiguruj środowisko
RemoteHost-->>RemoteManager: Status konfiguracji
end
alt Wystąpił błąd
Orchestrator->>DiagnosticsEngine: Zdiagnozuj problem
DiagnosticsEngine-->>Orchestrator: Sugestie rozwiązania
Orchestrator-->>CLI: Wyświetl diagnostykę
else Sukces
Orchestrator-->>CLI: Zwróć status sukcesu
end
CLI-->>User: Wyświetl wynik
Struktura modułów UnitMCP
classDiagram
class Orchestrator {
+project_detector: ProjectDetector
+dependency_manager: DependencyManager
+diagnostics: DiagnosticsEngine
+network: NetworkManager
+remote: RemoteManager
+clone_repository()
+detect_project_type()
+install_dependencies()
+setup_environment()
+run_application()
+process_project()
}
class ProjectDetector {
+detect_project_type()
}
class DependencyManager {
+check_tool_available()
+install_tool()
+install_dependencies()
}
class DiagnosticsEngine {
+error_patterns: Dict
+analyze_error()
+check_network_connectivity()
+check_system_requirements()
+diagnose_network_issue()
+diagnose_port_issue()
+diagnose_git_issue()
}
class NetworkManager {
+connect_ssh()
+setup_remote_environment()
+run_remote_command()
}
class RemoteManager {
+deploy()
+run_command()
}
Orchestrator --> ProjectDetector
Orchestrator --> DependencyManager
Orchestrator --> DiagnosticsEngine
Orchestrator --> NetworkManager
Orchestrator --> RemoteManager
Przepływ diagnostyki
flowchart TD
Start([Start]) --> DetectError[Wykryj błąd]
DetectError --> AnalyzeError[Analizuj błąd]
AnalyzeError --> IsNetworkIssue{Problem z siecią?}
IsNetworkIssue -->|Tak| DiagnoseNetwork[Diagnozuj sieć]
IsNetworkIssue -->|Nie| IsGitIssue{Problem z Git?}
IsGitIssue -->|Tak| DiagnoseGit[Diagnozuj Git]
IsGitIssue -->|Nie| IsDependencyIssue{Problem z zależnościami?}
IsDependencyIssue -->|Tak| DiagnoseDependencies[Diagnozuj zależności]
IsDependencyIssue -->|Nie| DiagnoseOther[Diagnozuj inne problemy]
DiagnoseNetwork --> GenerateSuggestions[Generuj sugestie]
DiagnoseGit --> GenerateSuggestions
DiagnoseDependencies --> GenerateSuggestions
DiagnoseOther --> GenerateSuggestions
GenerateSuggestions --> DisplaySuggestions[Wyświetl sugestie]
DisplaySuggestions --> CanAutoFix{Możliwa automatyczna naprawa?}
CanAutoFix -->|Tak| AutoFix[Napraw automatycznie]
CanAutoFix -->|Nie| ManualFix[Sugeruj ręczną naprawę]
AutoFix --> End([Koniec])
ManualFix --> End
style Start fill:#f96,stroke:#333,stroke-width:2px,color:#333
style End fill:#f96,stroke:#333,stroke-width:2px,color:#333
style GenerateSuggestions fill:#bbf,stroke:#333,stroke-width:2px,color:#333
style AutoFix fill:#bfb,stroke:#333,stroke-width:2px,color:#333
Główne funkcje
- Zarządzanie repozytoriami: klonowanie, aktualizacja, synchronizacja
- Zarządzanie zależnościami: automatyczne wykrywanie, instalacja i rozwiązywanie konfliktów wersji pakietów
- Diagnostyka i naprawa: inteligentne wykrywanie i rozwiązywanie problemów
- Automatyzacja wdrożeń: instalacja, uruchamianie, monitorowanie aplikacji
- Integracja z CI/CD: obsługa GitLab CI, GitHub Actions, Terraform, Jenkins, Docker, Kubernetes, Ansible, AWS, Azure i Google Cloud
- Baza danych rozwiązań: aktualizowana baza wiedzy dotycząca popularnych problemów
- Zdalne wdrażanie: instalacja i konfiguracja aplikacji na zdalnych maszynach (np. Raspberry Pi)
- Wieloplatformowe wsparcie: uruchamianie aplikacji w różnych środowiskach (Python, Node.js, PHP, Shell, HTML)
Zdalne wdrażanie (Remote)
Infrash umożliwia zdalne wdrażanie aplikacji na serwerach i urządzeniach IoT, takich jak Raspberry Pi. Funkcjonalność ta jest dostępna poprzez polecenie infrash remote.
Integracja z CI/CD
Infrash oferuje rozbudowaną integrację z popularnymi narzędziami CI/CD, umożliwiając automatyzację procesów testowania, budowania i wdrażania aplikacji. Obsługiwane formaty i platformy:
Systemy CI/CD
- GitLab CI: Pełna integracja z GitLab CI/CD pipeline
- GitHub Actions: Zautomatyzowane workflow dla repozytoriów GitHub
- Jenkins: Integracja z Jenkins Pipeline
Infrastruktura jako kod
- Terraform: Szablony do zarządzania infrastrukturą w chmurze
- Ansible: Automatyzacja konfiguracji i wdrażania
- Kubernetes: Orkiestracja kontenerów
- Docker: Konteneryzacja aplikacji
Dostawcy chmury
- AWS: Integracja z Amazon Web Services (CloudFormation)
- Azure: Integracja z Microsoft Azure (ARM Templates)
- Google Cloud: Integracja z Google Cloud Platform (Deployment Manager)
Przykłady konfiguracji dla wszystkich obsługiwanych formatów można znaleźć w katalogu examples/templates/.
Wdrażanie aplikacji na zdalnych hostach
infrash remote deploy --host <adres_ip> --user <użytkownik> --repo <url_repozytorium> [--key <ścieżka_do_klucza>] [--branch <gałąź>] [--no-deps]
Przykład:
infrash remote deploy --host 192.168.1.100 --user pi --repo https://github.com/example/app.git --branch main
Uruchamianie poleceń na zdalnych hostach
infrash remote run --host <adres_ip> --user <użytkownik> --command "<polecenie>" [--key <ścieżka_do_klucza>]
Przykład:
infrash remote run --host 192.168.1.100 --user pi --command "ls -la /home/pi/app"
Architektura modułu Remote
graph TB
CLI[CLI] --> RemoteManager[Remote Manager]
RemoteManager --> SSHClient[SSH Client]
RemoteManager --> EnvironmentSetup[Environment Setup]
RemoteManager --> CommandRunner[Command Runner]
SSHClient --> RemoteHost[(Remote Host)]
EnvironmentSetup --> RemoteHost
CommandRunner --> RemoteHost
style RemoteManager fill:#f9f,stroke:#333,stroke-width:2px,color:#333
style SSHClient fill:#bbf,stroke:#333,stroke-width:2px,color:#333
style EnvironmentSetup fill:#bfb,stroke:#333,stroke-width:2px,color:#333
style CommandRunner fill:#fbf,stroke:#333,stroke-width:2px,color:#333
Przepływ zdalnego wdrażania
sequenceDiagram
participant User as Użytkownik
participant CLI
participant RemoteManager
participant SSHClient
participant RemoteHost
User->>CLI: infrash remote deploy
CLI->>RemoteManager: Wywołaj deploy()
RemoteManager->>SSHClient: Nawiąż połączenie SSH
SSHClient->>RemoteHost: Połącz z hostem
RemoteHost-->>SSHClient: Połączenie nawiązane
RemoteManager->>RemoteHost: Zainstaluj zależności systemowe
RemoteHost-->>RemoteManager: Zależności zainstalowane
RemoteManager->>RemoteHost: Sklonuj repozytorium
RemoteHost-->>RemoteManager: Repozytorium sklonowane
RemoteManager->>RemoteHost: Utwórz środowisko wirtualne
RemoteHost-->>RemoteManager: Środowisko utworzone
RemoteManager->>RemoteHost: Zainstaluj zależności Python
RemoteHost-->>RemoteManager: Zależności zainstalowane
RemoteManager-->>CLI: Wdrożenie zakończone
CLI-->>User: Wyświetl status wdrożenia
Instalacja
Instalacja z PyPI
pip install infrash
Instalacja z repozytorium
git clone https://github.com/infrash/python.git
cd infrash
pip install -e .
Uruchomienie bez instalacji
Repozytorium zawiera skrypt run.sh, który automatycznie instaluje pakiet w trybie deweloperskim i uruchamia aplikację:
./run.sh [komenda] [argumenty]
Skrypt ten sprawdzi, czy pakiet infrash jest zainstalowany, a jeśli nie, zainstaluje go automatycznie przed uruchomieniem.
Szybki start
# Inicjalizacja projektu
infrash init
# lub
./run.sh init
# Klonowanie repozytorium
infrash repo clone https://github.com/username/project.git
# lub
./run.sh repo clone https://github.com/username/project.git
# Instalacja zależności
infrash install
# lub
./run.sh install
# Uruchomienie aplikacji
infrash start
# lub
./run.sh start
# Sprawdzenie statusu
infrash status
# lub
./run.sh status
# Zdiagnozowanie problemów
infrash diagnose
# lub
./run.sh diagnose
Zaawansowane użycie
Uruchomienie z pełną diagnostyką
infrash start --diagnostic-level=full
# lub
./run.sh start --diagnostic-level=full
Automatyczna naprawa problemu
infrash repair --auto
# lub
./run.sh repair --auto
Aktualizacja bazy danych rozwiązań
infrash solutions update
# lub
./run.sh solutions update
Zdalne wdrażanie na Raspberry Pi
infrash remote deploy --host 192.168.188.154 --user pi --repo https://github.com/UnitApi/mcp.git
# lub
./run.sh remote deploy --host 192.168.188.154 --user pi --repo https://github.com/UnitApi/mcp.git
Zdalne wdrażanie z rozwiązywaniem konfliktów zależności
infrash remote deploy --host 192.168.188.154 --user pi --repo https://github.com/UnitApi/mcp.git --resolve-deps
# lub
./run.sh remote deploy --host 192.168.188.154 --user pi --repo https://github.com/UnitApi/mcp.git --resolve-deps
Uruchomienie aplikacji z repozytorium Git
infrash runner --repo https://github.com/username/project.git --type python
# lub
./run.sh runner --repo https://github.com/username/project.git --type python
Orchestrator
Infrash zawiera moduł orchestratora, który umożliwia zarządzanie wieloma wdrożeniami jednocześnie. Orchestrator pozwala na:
- Równoległe wdrażanie na wielu maszynach
- Koordynację aktualizacji między różnymi systemami
- Automatyczne wykrywanie i naprawę problemów
- Monitorowanie stanu wszystkich wdrożeń
Przykłady użycia orchestratora można znaleźć w katalogu examples/orchestrator/.
Architektura Orchestratora
graph TB
CLI[CLI] --> Orchestrator
subgraph "Orchestrator Module"
Orchestrator[Orchestrator] --> ProjectDetector
Orchestrator --> DependencyManager
Orchestrator --> DiagnosticsEngine
Orchestrator --> NetworkManager
Orchestrator --> RemoteManager
ProjectDetector --> FilePatterns[(File Patterns)]
DependencyManager --> ToolInstaller[Tool Installer]
DiagnosticsEngine --> ErrorPatterns[(Error Patterns)]
NetworkManager --> SSHClient[SSH Client]
RemoteManager --> RemoteHost[(Remote Host)]
ToolInstaller --> SystemPackages[(System Packages)]
ToolInstaller --> LanguagePackages[(Language Packages)]
end
Orchestrator --> GitRepos[(Git Repositories)]
Orchestrator --> RunningApps[(Running Applications)]
NetworkManager --> RemoteHosts[(Remote Hosts)]
style Orchestrator fill:#f9f,stroke:#333,stroke-width:2px,color:#333
style ProjectDetector fill:#bbf,stroke:#333,stroke-width:2px,color:#333
style DependencyManager fill:#bfb,stroke:#333,stroke-width:2px,color:#333
style DiagnosticsEngine fill:#fbf,stroke:#333,stroke-width:2px,color:#333
style NetworkManager fill:#ff9,stroke:#333,stroke-width:2px,color:#333
style RemoteManager fill:#ff9,stroke:#333,stroke-width:2px,color:#333
Zależności
Infrash wymaga następujących pakietów:
- Python 3.8+
- Git
- click>=8.0.0
- GitPython>=3.1.0
- requests>=2.25.0
- rich>=10.0.0
- pyyaml>=6.0
- psutil>=5.9.0
- packaging>=21.0
- Paramiko (dla zdalnych wdrożeń)
Wszystkie zależności zostaną automatycznie zainstalowane podczas instalacji pakietu.
Rozwiązywanie problemów
Brak modułu unitmcp
Jeśli napotkasz błąd No module named 'unitmcp', oznacza to, że próbujesz uruchomić funkcje, które wymagają pakietu unitmcp. Ten pakiet jest opcjonalny i używany tylko do integracji z projektem UnitMCP. Możesz:
-
Zainstalować pakiet unitmcp, jeśli potrzebujesz tej funkcjonalności:
pip install unitmcp
-
Używać tylko funkcji infrash, które nie wymagają unitmcp.
Zarządzanie zależnościami
Infrash oferuje zaawansowany system zarządzania zależnościami, który umożliwia:
- Automatyczne wykrywanie i instalację wymaganych pakietów
- Inteligentne rozwiązywanie konfliktów wersji pakietów
- Sprawdzanie zgodności zainstalowanych pakietów z wymaganiami projektu
- Automatyczne naprawianie problemów z zależnościami
- Obsługę ponownych prób instalacji w przypadku problemów sieciowych
Sprawdzanie zależności
infrash deps check
Polecenie to sprawdza, czy wszystkie wymagane zależności są zainstalowane i w odpowiednich wersjach. Wyświetla szczegółowy raport o stanie każdego pakietu.
Instalacja zależności
infrash deps install [--resolve]
Instaluje wszystkie zależności projektu. Opcja --resolve włącza automatyczne rozwiązywanie konfliktów wersji pakietów.
Rozwiązywanie konfliktów wersji
infrash deps resolve
Automatycznie rozwiązuje konflikty wersji pakietów w pliku requirements.txt, znajdując najbliższe dostępne wersje lub wybierając najnowszą wersję w przypadku konfliktów.
Architektura systemu zarządzania zależnościami
graph TB
CLI[CLI] --> DependencyResolver[Dependency Resolver]
DependencyResolver --> VersionFinder[Version Finder]
DependencyResolver --> ConflictResolver[Conflict Resolver]
DependencyResolver --> DependencyChecker[Dependency Checker]
DependencyResolver --> RetryManager[Retry Manager]
VersionFinder --> PyPI[(PyPI)]
ConflictResolver --> RequirementsProcessor[Requirements Processor]
DependencyChecker --> InstalledPackages[(Installed Packages)]
RetryManager --> NetworkHandler[Network Handler]
style DependencyResolver fill:#f9f,stroke:#333,stroke-width:2px,color:#333
style VersionFinder fill:#bbf,stroke:#333,stroke-width:2px,color:#333
style ConflictResolver fill:#bfb,stroke:#333,stroke-width:2px,color:#333
style RetryManager fill:#fbf,stroke:#333,stroke-width:2px,color:#333
Przepływ rozwiązywania konfliktów zależności
sequenceDiagram
participant User as Użytkownik
participant CLI
participant DependencyResolver
participant PyPI
User->>CLI: infrash deps resolve
CLI->>DependencyResolver: Wywołaj resolve_dependency_conflicts()
DependencyResolver->>DependencyResolver: Odczytaj requirements.txt
DependencyResolver->>PyPI: Pobierz dostępne wersje pakietów
PyPI-->>DependencyResolver: Lista dostępnych wersji
DependencyResolver->>DependencyResolver: Znajdź konflikty wersji
DependencyResolver->>DependencyResolver: Wybierz najlepsze wersje
DependencyResolver->>DependencyResolver: Utwórz zaktualizowany plik requirements
DependencyResolver-->>CLI: Zwróć listę rozwiązanych konfliktów
CLI-->>User: Wyświetl raport
Licencja
Autor
- Tom Sapletta
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file infrash-0.1.9.tar.gz.
File metadata
- Download URL: infrash-0.1.9.tar.gz
- Upload date:
- Size: 388.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c2a9cefacd6a27db062c559e0ba6848a0147044129ba5bff30e8cf57d8f9a52f
|
|
| MD5 |
0534e9275b9ff58ca3b8968d8cdb875a
|
|
| BLAKE2b-256 |
832fd32a48ec71ab3e1eaa9296e667006292c46d225dbec7a4fa36f90a3d6fb7
|
File details
Details for the file infrash-0.1.9-py3-none-any.whl.
File metadata
- Download URL: infrash-0.1.9-py3-none-any.whl
- Upload date:
- Size: 530.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0402490a2330811ac6c08b98bfb0cd045fa01492e43bab46eeea5afad6fde964
|
|
| MD5 |
b7d5018f6577a5b72fa52e22379b1405
|
|
| BLAKE2b-256 |
f73d74b0b2957691194d41516bd8c45497d6e8c0735d65f0a69f866c553e0752
|