-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstart_api.sh
More file actions
executable file
·94 lines (87 loc) · 2.52 KB
/
start_api.sh
File metadata and controls
executable file
·94 lines (87 loc) · 2.52 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
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
#!/bin/bash
# Check if Python is available
if ! command -v python3 &> /dev/null; then
echo "❌ Python3 is required but not found!"
exit 1
fi
# Check if procwatch can be imported
if ! python3 -c "from procwatch.api import run_api_server" 2>/dev/null; then
echo "❌ ProcWatch modules not found. Make sure you're in the correct directory."
exit 1
fi
# Default values
HOST="${HOST:-0.0.0.0}"
PORT="${PORT:-8080}"
CONFIG="${CONFIG:-}"
MODEL="${MODEL:-}"
# Parse command line arguments
while [[ $# -gt 0 ]]; do
case $1 in
--host)
HOST="$2"
shift 2
;;
--port)
PORT="$2"
shift 2
;;
--config)
CONFIG="--config $2"
shift 2
;;
--model)
MODEL="--model $2"
shift 2
;;
--help)
echo "Usage: $0 [OPTIONS]"
echo ""
echo "Options:"
echo " --host HOST Host to bind to (default: 0.0.0.0)"
echo " --port PORT Port to bind to (default: 8080)"
echo " --config FILE Config YAML file"
echo " --model FILE ML model file"
echo " --help Show this help"
echo ""
echo "Environment variables:"
echo " HOST Same as --host"
echo " PORT Same as --port"
echo " CONFIG Same as --config"
echo " MODEL Same as --model"
echo ""
echo "Examples:"
echo " $0"
echo " $0 --port 9000"
echo " $0 --host localhost --port 8080"
echo " PORT=9000 $0"
exit 0
;;
*)
echo "Unknown option: $1"
echo "Use --help for usage information"
exit 1
;;
esac
done
echo "📋 Configuration:"
echo " Host: $HOST"
echo " Port: $PORT"
echo ""
# Start the server
echo "✅ Starting server..."
python3 procwatch.py api --host "$HOST" --port "$PORT" $CONFIG $MODEL &
SERVER_PID=$!
echo "📡 API Endpoints:"
echo " http://$HOST:$PORT/api"
echo " http://$HOST:$PORT/api/stats"
echo " http://$HOST:$PORT/api/processes"
echo " http://$HOST:$PORT/api/suspicious"
echo ""
echo "🌐 Web UI:"
echo " Open webui.html in your browser"
if [ "$HOST" = "0.0.0.0" ]; then
echo " (Update API_BASE to http://localhost:$PORT/api if needed)"
else
echo " (Update API_BASE to http://$HOST:$PORT/api if needed)"
fi
wait $SERVER_PID