当前位置:网站首页>Flash operation and maintenance script (running for a long time)
Flash operation and maintenance script (running for a long time)
2022-07-06 09:56:00 【east】
flask Every time the project is opened, it will automatically close .
I heard that brother afar (QQ25008793) Write a script for me .... An awesome batch ..
Run in the background and Shell Exit the program and still run the command :
nohup app.py & In the actual process , We usually use scripts , The other is to use docker k8s Automatic arrangement .
Write a script for you .
Upload the script to this directory and you can use it , The way
sh ./start.sh start
start.sh The code is as follows :
function start(){
if [ ! -d 'venv' ]; then
python3 -m venv venv
fi
source venv/bin/activate
# requirements.txt
if [ ! -e 'requirements.txt' ]; then
echo 'error: "requirements.txt" file not found!'
exit
fi
pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
nohup python app.py & echo $! > app.pid
echo "run app.py pid:$(cat app.pid)"
}
function stop() {
if [ -e 'app.pid' ]; then
pid=$(cat app.pid)
rm -rf 'app.pid'
for line in $(ps -ef|grep python|awk '{print $2}')
do
if [ $pid = $line ]; then
echo "kill: $pid"
kill $pid
fi
done
fi
}
function status() {
if [ -e 'app.id' ]; then
pid=$(cat 'app.id')
for line in $(ps -ef|grep python|awk '{print $2}')
do
if [ $pid = $line ]; then
echo "app.py ok $pid"
fi
done
fi
}
function main(){
command=$1
case command in
'start')
start
;;
'stop')
stop
;;
'restart')
stop
start
;;
'status')
status
;;
*)
echo '-------------------------- The list of commands --------------------------'
echo '| start start-up |'
echo '| stop stop it |'
echo '| restart restart |'
echo '| status state |'
echo '-----------------------------------------------------------'
;;
}
# --------------------------
main $*
边栏推荐
- Download address of canoe, download and activation of can demo 16, and appendix of all canoe software versions
- Cap theory
- CANoe下载地址以及CAN Demo 16的下载与激活,并附录所有CANoe软件版本
- Redis distributed lock implementation redison 15 questions
- Vh6501 Learning Series
- MySQL ERROR 1040: Too many connections
- The replay block of canoe still needs to be combined with CAPL script to make it clear
- 五月刷题01——数组
- Zsh configuration file
- 面试突击62:group by 有哪些注意事项?
猜你喜欢

Programmation défensive en langage C dans le développement intégré

Carolyn Rosé博士的社交互通演讲记录

嵌入式开发比单片机要难很多?谈谈单片机和嵌入式开发设计经历

Embedded development is much more difficult than MCU? Talk about SCM and embedded development and design experience

Counter attack of noodles: redis asked 52 questions in a series, with detailed pictures and pictures. Now the interview is stable

学习单片机对社会的帮助是很大的

机械工程师和电气工程师方向哪个前景比较好?

CANoe的数据回放(Replay Block),还是要结合CAPL脚本才能说的明白
![[CV] target detection: derivation of common terms and map evaluation indicators](/img/e8/04cc8336223c0ab2dea5638def88df.jpg)
[CV] target detection: derivation of common terms and map evaluation indicators

CAPL 脚本对.ini 配置文件的高阶操作
随机推荐
Control the operation of the test module through the panel in canoe (Advanced)
六月刷题02——字符串
嵌入式中的合作开发--函数指针
Cap theory
Why can't TN-C use 2p circuit breaker?
Why is 51+ assembly in college SCM class? Why not come directly to STM32
Contest3145 - the 37th game of 2021 freshman individual training match_ B: Password
MapReduce instance (V): secondary sorting
tn-c为何不可用2p断路器?
Competition vscode Configuration Guide
机械工程师和电气工程师方向哪个前景比较好?
五月刷题27——图
Une grande vague d'attaques à la source ouverte
Defensive C language programming in embedded development
NLP路线和资源
PR 2021 quick start tutorial, first understanding the Premiere Pro working interface
Contest3145 - the 37th game of 2021 freshman individual training match_ C: Tour guide
The programming ranking list came out in February. Is the result as you expected?
Carolyn Rosé博士的社交互通演讲记录
CANoe的数据回放(Replay Block),还是要结合CAPL脚本才能说的明白