Skip to content

Commit 819d578

Browse files
Merge pull request #41 from shadab-mohammad-oracle/patch-5
Update stop.sh
2 parents cfa7bb9 + b5ab35d commit 819d578

File tree

1 file changed

+12
-17
lines changed

1 file changed

+12
-17
lines changed

stop.sh

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,17 @@
11
#!/bin/bash
22

3-
SSL_DIR="ssl"
4-
KEY_FILE="$SSL_DIR/key.pem"
5-
CERT_FILE="$SSL_DIR/cert.pem"
6-
7-
if [[ ! -f ".venv/bin/activate" ]]; then
8-
echo "❌ Python virtual environment not found. Please run build.sh first."
9-
exit 1
3+
PID=$(ps aux | grep 'uvicorn app.main:app' | grep -v grep | awk '{print $2}')
4+
if [ -z "$PID" ]; then
5+
echo "No uvicorn process found running app.main:app."
6+
exit 0
107
fi
118

12-
if [[ ! -f "$KEY_FILE" || ! -f "$CERT_FILE" ]]; then
13-
echo "❌ SSL certificate or key missing. Please run build.sh first."
14-
exit 1
9+
echo "Stopping uvicorn process (PID $PID)..."
10+
kill "$PID"
11+
sleep 2
12+
if ps -p $PID > /dev/null; then
13+
echo "uvicorn (PID $PID) did not stop, sending SIGKILL."
14+
kill -9 "$PID"
15+
else
16+
echo "uvicorn stopped."
1517
fi
16-
17-
echo "🔑 Activating virtual environment..."
18-
# shellcheck source=/dev/null
19-
source .venv/bin/activate
20-
21-
echo "🚦 Starting uvicorn server with HTTPS (https://localhost:8000)"
22-
uvicorn app.main:app --host 0.0.0.0 --port 8000 --ssl-keyfile "$KEY_FILE" --ssl-certfile "$CERT_FILE"

0 commit comments

Comments
 (0)