当前位置:网站首页>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 $*
边栏推荐
- 17 医疗挂号系统_【微信支付】
- Interview shock 62: what are the precautions for group by?
- VH6501学习系列文章
- 五月集训总结——来自阿光
- Keep these four requirements in mind when learning single chip microcomputer with zero foundation and avoid detours
- Yarn organizational structure
- Some thoughts on the study of 51 single chip microcomputer
- 学习单片机对社会的帮助是很大的
- 零基础学习单片机切记这四点要求,少走弯路
- Write your own CPU Chapter 10 - learning notes
猜你喜欢

CANoe仿真功能之自动化序列(Automation Sequences )

Release of the sample chapter of "uncover the secrets of asp.net core 6 framework" [200 pages /5 chapters]

Several silly built-in functions about relative path / absolute path operation in CAPL script
![[one click] it only takes 30s to build a blog with one click - QT graphical tool](/img/f0/52e1ea33a5abfce24c4a33d107ea05.jpg)
[one click] it only takes 30s to build a blog with one click - QT graphical tool

西南大学:胡航-关于学习行为和学习效果分析

MapReduce instance (VII): single table join

51单片机进修的一些感悟

Hero League rotation chart manual rotation

tn-c为何不可用2p断路器?

嵌入式開發中的防禦性C語言編程
随机推荐
Take you back to spark ecosystem!
Delayed note learning
C杂讲 双向循环链表
通过bat脚本配置系统环境变量
MapReduce instance (V): secondary sorting
CANoe的数据回放(Replay Block),还是要结合CAPL脚本才能说的明白
Target detection -- yolov2 paper intensive reading
MapReduce instance (VI): inverted index
Yarn organizational structure
一大波开源小抄来袭
Summary of May training - from a Guang
A wave of open source notebooks is coming
五月刷题26——并查集
The programming ranking list came out in February. Is the result as you expected?
宝塔的安装和flask项目部署
单片机实现模块化编程:思维+实例+系统教程(实用程度令人发指)
五月刷题27——图
May brush question 01 - array
Leetcode:608 tree node
NLP路线和资源