当前位置:网站首页>flask运维脚本(长时间运行)
flask运维脚本(长时间运行)
2022-07-06 09:05:00 【东方】
flask项目每次开启完总会自动关闭了。
听闻远方哥(QQ25008793)给我手写了一个脚本。。。。牛逼的一批。。
后台运行并且Shell退出程序依然运行使用命令:
nohup app.py & 在实际过程中,我们一般用脚本,另外就是用 docker k8s 自动编排。
给你写一个脚本。
脚本上传到这个目录就可以使用了,方式
sh ./start.sh start
start.sh代码如下:
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 '--------------------------命令列表--------------------------'
echo '| start 启动 |'
echo '| stop 停止 |'
echo '| restart 重启 |'
echo '| status 状态 |'
echo '-----------------------------------------------------------'
;;
}
# --------------------------
main $*
边栏推荐
- 嵌入式中的合作开发--函数指针
- Teach you how to write the first MCU program hand in hand
- Competition vscode Configuration Guide
- 【深度學習】語義分割-源代碼匯總
- Hugo blog graphical writing tool -- QT practice
- 112 pages of mathematical knowledge sorting! Machine learning - a review of fundamentals of mathematics pptx
- 五月刷题03——排序
- Compress decompress
- CAPL script pair High level operation of INI configuration file
- If a university wants to choose to study automation, what books can it read in advance?
猜你喜欢

MapReduce instance (VIII): Map end join
![[deep learning] semantic segmentation - source code summary](/img/2c/50eaef4a11fe2ee9c53a5cebdd69ce.png)
[deep learning] semantic segmentation - source code summary

听哥一句劝,按这套嵌入式的课程内容和课程体系去学习

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

【深度学习】语义分割:论文阅读:(CVPR 2022) MPViT(CNN+Transformer):用于密集预测的多路径视觉Transformer
![[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

C#/. Net phase VI 01C Foundation_ 01: running environment, process of creating new C program, strict case sensitivity, meaning of class library

在CANoe中通过Panel面板控制Test Module 运行(高级)

Listen to my advice and learn according to this embedded curriculum content and curriculum system

Combined search /dfs solution - leetcode daily question - number of 1020 enclaves
随机推荐
Download address of canoe, download and activation of can demo 16, and appendix of all canoe software versions
Compress decompress
Scoped in webrtc_ refptr
Learning SCM is of great help to society
May brush question 03 - sorting
Nc29 search in two-dimensional array
May brush question 02 - string
CAPL 脚本对.ini 配置文件的高阶操作
Mapreduce实例(七):单表join
单片机如何从上电复位执行到main函数?
June brush question 02 - string
33岁可以学PLC吗
CAPL脚本中关于相对路径/绝对路径操作的几个傻傻分不清的内置函数
听哥一句劝,按这套嵌入式的课程内容和课程体系去学习
Tianmu MVC audit II
【深度学习】语义分割-源代码汇总
Une grande vague d'attaques à la source ouverte
大学想要选择学习自动化专业,可以看什么书去提前了解?
Canoe CAPL file operation directory collection
MapReduce working mechanism