当前位置:网站首页>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 $*
边栏推荐
- MapReduce working mechanism
- 四川云教和双师模式
- Single chip microcomputer realizes modular programming: Thinking + example + system tutorial (the degree of practicality is appalling)
- max-flow min-cut
- [NLP] bert4vec: a sentence vector generation tool based on pre training
- May brush question 27 - figure
- What you have to know about network IO model
- Cooperative development in embedded -- function pointer
- The 32 year old programmer left and was admitted by pinduoduo and foreign enterprises. After drying out his annual salary, he sighed: it's hard to choose
- Contrôle de l'exécution du module d'essai par panneau dans Canoe (primaire)
猜你喜欢
Solve the problem of too many small files
大学想要选择学习自动化专业,可以看什么书去提前了解?
一大波开源小抄来袭
西南大学:胡航-关于学习行为和学习效果分析
寶塔的安裝和flask項目部署
Control the operation of the test module through the panel in canoe (Advanced)
Hero League rotation chart manual rotation
嵌入式開發中的防禦性C語言編程
Hugo blog graphical writing tool -- QT practice
MapReduce instance (VII): single table join
随机推荐
Some thoughts on the study of 51 single chip microcomputer
《ASP.NET Core 6框架揭秘》样章发布[200页/5章]
Contest3145 - the 37th game of 2021 freshman individual training match_ B: Password
学习单片机对社会的帮助是很大的
Day 5 of MySQL learning
五月刷题01——数组
CANoe下载地址以及CAN Demo 16的下载与激活,并附录所有CANoe软件版本
Delayed note learning
Upload vulnerability
Combined search /dfs solution - leetcode daily question - number of 1020 enclaves
Automation sequences of canoe simulation functions
The programming ranking list came out in February. Is the result as you expected?
018. Valid palindromes
Can I learn PLC at the age of 33
May brush question 26 - concurrent search
vscode 常用的指令
MapReduce instance (x): chainmapreduce
jar运行报错no main manifest attribute
Elk project monitoring platform deployment + deployment of detailed use (II)
Hugo blog graphical writing tool -- QT practice