Spaces:
Running
Running
| cd "$(dirname "$0")" | |
| source ~/.bashrc | |
| # Check if PID file exists AND process is actually running | |
| if [ -f deepshell.pid ]; then | |
| PID=$(cat deepshell.pid) | |
| if kill -0 $PID 2>/dev/null; then | |
| echo "DeepShell already running (PID $PID)" | |
| exit 1 | |
| else | |
| echo "Stale PID found, cleaning up..." | |
| rm -f deepshell.pid | |
| fi | |
| fi | |
| # Start LibreTranslate if not already running | |
| if ! pgrep -f "libretranslate" > /dev/null; then | |
| source ~/.venvs/libretranslate/bin/activate | |
| nohup libretranslate --host 0.0.0.0 --port 5000 --load-only en,hi > libretranslate.log 2>&1 & | |
| echo $! > libretranslate.pid | |
| echo "LibreTranslate started (PID $(cat libretranslate.pid))" | |
| deactivate | |
| # Warmup — trigger model load in background | |
| sleep 5 && curl -s -X POST http://localhost:5000/translate -H "Content-Type: application/json" -d '{"q":"warmup","source":"en","target":"hi"}' > /dev/null 2>&1 & | |
| echo "LibreTranslate warmup triggered" | |
| else | |
| echo "LibreTranslate already running" | |
| fi | |
| # Explicitly pass GROQ_API_KEY to subprocess | |
| GROQ_API_KEY=$GROQ_API_KEY nohup python run_deepshell.py > deepshell.log 2>&1 & | |
| echo $! > deepshell.pid | |
| echo "DeepShell started (PID $(cat deepshell.pid))" | |
| echo "Logs: tail -f $(pwd)/deepshell.log" | |