Spaces:
Runtime error
Runtime error
File size: 3,058 Bytes
7566eb5 | 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 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | #!/usr/bin/env python3
"""
Docker Startup Script for ISUP 5.0 Server
Optimized for containerized deployment
"""
import asyncio
import sys
import signal
import threading
import os
from datetime import datetime
# Import our servers
from app_isup5 import app
from isup5_server import isup_server
import uvicorn
def signal_handler(signum, frame):
"""Handle shutdown signals"""
print(f"\nπ Received signal {signum}, shutting down...")
sys.exit(0)
def print_docker_banner():
"""Print Docker startup banner"""
print("=" * 60)
print("π³ HIKVISION ISUP 5.0 SERVER (DOCKER)")
print("=" * 60)
print(f"π
Started: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}")
print(f"π Protocol: ISUP 5.0 Binary")
print(f"π§ Authentication: EHome Key + Session Key")
print(f"π‘ ISUP Port: 7660 (TCP)")
print(f"π Web Interface: http://0.0.0.0:7860")
print(f"π³ Container Mode: Production")
print("=" * 60)
print()
print("π§ DEVICE CONFIGURATION:")
print("Configure your Hikvision device with these settings:")
print(" β’ Platform Access Mode: ISUP")
print(" β’ Protocol Version: 5.0")
print(" β’ Server Address: <container-host-ip>")
print(" β’ Port: 7660")
print(" β’ Device ID: 255")
print(" β’ EHome Key: hikvision123")
print()
print("π± SUPPORTED DEVICE:")
print(" β’ Model: DS-K1T342MFX")
print(" β’ Serial: DS-K1T342MFX20220310V030305ENJ92377854")
print(" β’ Features: Face Recognition, Temperature, Mask Detection")
print()
# Show container networking info
hostname = os.environ.get('HOSTNAME', 'unknown')
print(f"π³ Container ID: {hostname}")
print("π Access URLs:")
print(" β’ Local: http://localhost:7860")
print(" β’ Container: http://0.0.0.0:7860")
if 'SPACE_ID' in os.environ:
space_id = os.environ['SPACE_ID']
print(f" β’ HuggingFace: https://{space_id}.hf.space")
print()
def main():
"""Main Docker startup function"""
# Set up signal handlers
signal.signal(signal.SIGINT, signal_handler)
signal.signal(signal.SIGTERM, signal_handler)
print_docker_banner()
try:
# Start the web server (which will start ISUP server in background)
print("π Starting ISUP 5.0 server in Docker container...")
# Use uvicorn directly for better Docker compatibility
uvicorn.run(
"app_isup5:app",
host="0.0.0.0", # Important: bind to all interfaces in Docker
port=7860,
reload=False, # Never use reload in production/Docker
log_level="info",
access_log=True,
workers=1 # Single worker for ISUP server compatibility
)
except KeyboardInterrupt:
print("\nπ Shutdown requested by user")
except Exception as e:
print(f"β Server error: {e}")
sys.exit(1)
finally:
print("π Server stopped")
if __name__ == "__main__":
main()
|