-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_loghawk.py
More file actions
65 lines (55 loc) · 1.93 KB
/
run_loghawk.py
File metadata and controls
65 lines (55 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# LogHawk Application Server
# Entry point for LogHawk - Advanced Log Analysis Platform
# Supports both HTTP and HTTPS protocols for maximum compatibility
import uvicorn
import asyncio
import threading
import time
import os
def run_http_server():
"""Run HTTP server on port 8765"""
print("[HTTP] Starting LogHawk HTTP server on http://127.0.0.1:8765")
uvicorn.run(
"log_server:app",
host="127.0.0.1",
port=8765,
log_level="info",
access_log=True
)
def run_https_server():
"""Run HTTPS server on port 8766 with self-signed certificates"""
ssl_cert_path = "./ssl/loghawk-cert.pem"
ssl_key_path = "./ssl/loghawk-key.pem"
# Check if SSL certificates exist
if not os.path.exists(ssl_cert_path) or not os.path.exists(ssl_key_path):
print(f"[HTTPS] SSL certificates not found:")
print(f"[HTTPS] Certificate: {ssl_cert_path}")
print(f"[HTTPS] Key: {ssl_key_path}")
print("[HTTPS] Skipping HTTPS server...")
return
print("[HTTPS] Starting LogHawk HTTPS server on https://127.0.0.1:8766")
print("[HTTPS] Using self-signed certificates (some clients may reject)")
uvicorn.run(
"log_server:app",
host="127.0.0.1",
port=8766,
log_level="info",
access_log=True,
ssl_keyfile=ssl_key_path,
ssl_certfile=ssl_cert_path
)
if __name__ == "__main__":
print("LogHawk - Advanced Log Analysis Platform")
print("=" * 60)
print("Starting dual-protocol servers...")
print("")
# Start HTTP server in a separate thread
http_thread = threading.Thread(target=run_http_server, daemon=True)
http_thread.start()
# Give HTTP server time to start
time.sleep(2)
# Start HTTPS server in main thread (this will block)
try:
run_https_server()
except KeyboardInterrupt:
print("\n[SHUTDOWN] Shutting down LogHawk servers...")