Stop local Flask server running on port 8080. Kills process cleanly using lsof or PID file. Use when stopping local Python development server.
Stops a locally running Flask server by killing the process on port 8080. Works for both foreground and background server instances.
Invoke this skill when the user:
Navigate to the server directory:
cd path/to/server/imp/py
Run the stop script:
./stop.sh
The script will:
If no script available:
lsof -ti:8080 | xargs kill
This finds and kills any process using port 8080.
If running in foreground mode:
Using stop.sh:
š Stopping Firefly server...
ā
Server stopped (PID: 12345)
Manual stop:
# Silent if successful, or:
kill: 12345: No such process (if already stopped)
stop.sh script:
if [ -f server.pid ]; then
PID=$(cat server.pid)
kill $PID
rm server.pid
echo "Server stopped"
else
# Fallback: kill by port
lsof -ti:8080 | xargs kill
fi
lsof method:
lsof -ti:8080: Lists process IDs using port 8080xargs kill: Pipes PIDs to kill commandCheck server is stopped:
# Try to curl - should fail
curl http://localhost:8080/api/ping
# Check port is free
lsof -ti:8080
# (no output = port free)
"No such process":
"Operation not permitted":
ps aux | grep python3Port still in use after stop:
lsof -ti:8080 | xargs kill -9server.pid file not found:
lsof -ti:8080 | xargs killSIGTERM (default kill):
SIGKILL (kill -9):
Always try SIGTERM first.
Before deploying:
./stop.sh
# Make changes
./start.sh
Before testing different port:
./stop.sh
# Edit app.py to use different port
python3 app.py
Before remote deployment:
./stop.sh # Stop local
# Deploy to remote with py-deploy-remote
When switching modes:
# Stop background server
./stop.sh
# Start foreground for debugging
python3 app.py
If port 8080 is used by another app:
Find what's using port:
lsof -i:8080
Output shows:
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
python3 12345 user 3u IPv4 0x... 0t0 TCP *:8080 (LISTEN)
Kill specific process:
kill 12345
The stop script cleans up:
Logs (server.log) are preserved for review.
This operation is idempotent:
Restart workflow:
Deploy workflow:
For production, use a process manager:
But for development, manual start/stop is simpler.