Skip to content

Instantly share code, notes, and snippets.

@seahrh
Created August 12, 2021 03:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seahrh/2cb3bf9bc0d5a864a005064ad1ce1bbe to your computer and use it in GitHub Desktop.
Save seahrh/2cb3bf9bc0d5a864a005064ad1ce1bbe to your computer and use it in GitHub Desktop.
kill processes
# kill all processes that match this command
pkill -u user -f "gunicorn myapp.app.main:app"
# kill sentence-transformers processes SIGKILL
pkill -9 -u user -f "myapp/venv/bin/python3 -c from multiprocessing"
# manual kill parent and child processes
# see uvicorn multiprocessing bug https://github.com/encode/uvicorn/issues/852
PARENT_PID=$(pgrep -u user -f "uvicorn myapp.app.main:app --port=1234")
# kill child processes
kill $(pgrep -P $PARENT_PID)
# kill parent process
kill "$PARENT_PID"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment