File size: 1,485 Bytes
2197ab7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/bin/bash

# Add the project root to PYTHONPATH
export PYTHONPATH="/home/jelle/Tools/pythagora-core/workspace/fabric_to_espanso:$PYTHONPATH"

# Create a log directory if it doesn't exist
LOG_DIR="/home/jelle/Tools/pythagora-core/workspace/fabric_to_espanso/logs"
mkdir -p "$LOG_DIR"
LOG_FILE="$LOG_DIR/streamlit.log"

# Clean up any existing nohup.out
if [ -f nohup.out ]; then
    cat /dev/null > nohup.out
fi

# Check if streamlit is already running on port 8501
if ss -tuln | grep -q ":8501 "; then
	echo "Port 8501 is already in use. No need to start the app again."
	exit 0
fi
	

# Run the streamlit app
echo "Starting Streamlit app..."
nohup /home/jelle/Tools/pythagora-core/workspace/fabric_to_espanso/.venv/bin/streamlit run ~/Tools/pythagora-core/workspace/fabric_to_espanso/src/search_qdrant/streamlit_app.py >> "LOG_FILE" 2>&1 &

echo "Streamlit process started with PID: $!"

# Wait a moment and check if the process is still running
sleep 2
if ps -p $! > /dev/null; then
    echo "Streamlit successfully started"
else
    echo "Failed to start Streamlit. Check $LOG_FILE for details"
    exit 1
fi
# Wait for Streamlit to start and capture its initial output
# max_attempts=5
# attempt=0
# while [ $attempt -lt $max_attempts ]; do
# 	if grep -q "You can now view your Streamlit app" streamlit.log; then
# 		cat streamlit.log | grep -A 3 "You can now view your Streamlit app"
# 		exit 0
# 	fi
# 	sleep 1
# 	((attempt++))
# done

# echo "Failed to start Streamlit server"