两个脚本,一个运行fastapi服务,一个重启服务:
启动服务先:
发现问题,杀掉 server.sh 后,依旧有:
不知道为什么会出现这个,直接kill吧:
server.sh:
#!/bin/bashparpath=/root/autodl-tmp/wgs/wav2motion/wav2motion
cd $parpath#python -W ignore ./server.py \
/root/miniconda3/bin/python ./server.py \--data_root $parpath \--speaker2id_path ./weights/speaker2id.json \--speaker_static_path ./weights/speaker_static.pkl \--face_model_path ./weights/all_face.ckpt \--Wav2Vec2Model_path ./weights/wav2vec2-xlsr-53-espeak-cv-ft \--body_vq_path ./weights/all_vq_best.ckpt \--body_pixel_path ./weights/all_pixel_best.ckpt \--device 'cuda:0' \--use_map_location 'cuda:0' \--app_name 'server:app' \--host '127.0.0.1' \--port 6006 \--reload True >>./log/server.log 2>>./log/server.err
cron_server.sh:
#!/bin/bashserverpath=/root/autodl-tmp/wgs/wav2motion/wav2motion/dk/server.shServerName1="server.sh"
ServerName2="server.py"
ServerName3="multiprocessing.resource_tracker"
ServerName4="multiprocessing.spawn"function start() {bash $serverpath
}function stop() {PIDS1=$(ps aux | grep "$ServerName1" | grep -v grep | awk '{print $2}')PIDS2=$(ps aux | grep "$ServerName2" | grep -v grep | awk '{print $2}')PIDS3=$(ps aux | grep "$ServerName3" | grep -v grep | awk '{print $2}')PIDS4=$(ps aux | grep "$ServerName4" | grep -v grep | awk '{print $2}')echo ${PIDS1} ${PIDS2} ${PIDS3} ${PIDS4}for pid in ${PIDS1} ${PIDS2} ${PIDS3} ${PIDS4}; doecho $pidkill -9 $piddone}function restart() {stopsleep 2start
}case $1 instart)start;;stop)stop;;restart)restart;;*)
esac