Skip to content

Update stop.sh #41

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 12 additions & 17 deletions stop.sh
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
#!/bin/bash

SSL_DIR="ssl"
KEY_FILE="$SSL_DIR/key.pem"
CERT_FILE="$SSL_DIR/cert.pem"

if [[ ! -f ".venv/bin/activate" ]]; then
echo "❌ Python virtual environment not found. Please run build.sh first."
exit 1
PID=$(ps aux | grep 'uvicorn app.main:app' | grep -v grep | awk '{print $2}')
if [ -z "$PID" ]; then
echo "No uvicorn process found running app.main:app."
exit 0
fi

if [[ ! -f "$KEY_FILE" || ! -f "$CERT_FILE" ]]; then
echo "❌ SSL certificate or key missing. Please run build.sh first."
exit 1
echo "Stopping uvicorn process (PID $PID)..."
kill "$PID"
sleep 2
if ps -p $PID > /dev/null; then
echo "uvicorn (PID $PID) did not stop, sending SIGKILL."
kill -9 "$PID"
else
echo "uvicorn stopped."
fi

echo "🔑 Activating virtual environment..."
# shellcheck source=/dev/null
source .venv/bin/activate

echo "🚦 Starting uvicorn server with HTTPS (https://localhost:8000)"
uvicorn app.main:app --host 0.0.0.0 --port 8000 --ssl-keyfile "$KEY_FILE" --ssl-certfile "$CERT_FILE"