feat: add initial health-check application
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
.venv/
|
||||
.env
|
||||
*.log
|
||||
@@ -0,0 +1,33 @@
|
||||
# DevOps Platform
|
||||
|
||||
Учебный проект для практики DevOps в течение 3 месяцев.
|
||||
|
||||
## Application
|
||||
|
||||
Минимальный HTTP-сервис на Python без внешних зависимостей.
|
||||
|
||||
## Endpoints
|
||||
|
||||
- GET / — информация о приложении
|
||||
- GET /health — проверка работоспособности
|
||||
- Другие пути — HTTP 404
|
||||
|
||||
## Local run
|
||||
|
||||
python3 app/app.py
|
||||
|
||||
Приложение слушает 127.0.0.1:8000.
|
||||
|
||||
## Health check
|
||||
|
||||
curl -i http://127.0.0.1:8000/health
|
||||
|
||||
## Roadmap
|
||||
|
||||
1. Git workflow
|
||||
2. Docker and Compose
|
||||
3. GitLab CI/CD
|
||||
4. Ansible
|
||||
5. Terraform
|
||||
6. Prometheus and Grafana
|
||||
7. Kubernetes
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
import json
|
||||
from http.server import BaseHTTPRequestHandler, HTTPServer
|
||||
|
||||
|
||||
class Handler(BaseHTTPRequestHandler):
|
||||
def do_GET(self):
|
||||
if self.path == "/health":
|
||||
status = 200
|
||||
body = {"status": "ok"}
|
||||
elif self.path == "/":
|
||||
status = 200
|
||||
body = {
|
||||
"application": "devops-platform",
|
||||
"version": "1.0.0"
|
||||
}
|
||||
else:
|
||||
status = 404
|
||||
body = {"error": "not found"}
|
||||
|
||||
payload = json.dumps(body).encode("utf-8")
|
||||
|
||||
self.send_response(status)
|
||||
self.send_header("Content-Type", "application/json")
|
||||
self.send_header("Content-Length", str(len(payload)))
|
||||
self.end_headers()
|
||||
self.wfile.write(payload)
|
||||
|
||||
def log_message(self, format, *args):
|
||||
print(f"{self.client_address[0]} - {format % args}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
server = HTTPServer(("127.0.0.1", 8000), Handler)
|
||||
print("Listening on http://127.0.0.1:8000")
|
||||
server.serve_forever()
|
||||
Reference in New Issue
Block a user