-
-
Save favarete/55d0aacffc3f23a9a577ce37a975515d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
source /home/project/myenv/bin/activate | |
cd /home/project/server | |
PID=$(ps aux | grep 'uvicorn myapp:app' | grep -v grep | awk {'print $2'} | xargs) | |
if [ "$PID" != "" ] | |
then | |
kill -9 $PID | |
sleep 2 | |
echo "" > nohup.out | |
echo "Restarting FastAPI server" | |
else | |
echo "No such process. Starting new FastAPI server" | |
fi | |
nohup uvicorn myapp:app & |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment