当前位置:网站首页>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 $*
边栏推荐
- Hugo blog graphical writing tool -- QT practice
- How can I take a shortcut to learn C language in college
- C杂讲 浅拷贝 与 深拷贝
- Oom happened. Do you know the reason and how to solve it?
- [deep learning] semantic segmentation: paper reading: (2021-12) mask2former
- Combined search /dfs solution - leetcode daily question - number of 1020 enclaves
- [deep learning] semantic segmentation: paper reading: (CVPR 2022) mpvit (cnn+transformer): multipath visual transformer for dense prediction
- Function description of shell command parser
- MapReduce instance (V): secondary sorting
- Some thoughts on the study of 51 single chip microcomputer
猜你喜欢
![[flask] crud addition and query operation of data](/img/fc/7a12ede31befed5f42b32b94ae5ecf.jpg)
[flask] crud addition and query operation of data

If a university wants to choose to study automation, what books can it read in advance?

Hard core! One configuration center for 8 classes!

Regular expressions are actually very simple

CANoe仿真功能之自动化序列(Automation Sequences )
![[deep learning] semantic segmentation: paper reading: (CVPR 2022) mpvit (cnn+transformer): multipath visual transformer for dense prediction](/img/f1/6f22f00843072fa4ad83dc0ef2fad8.png)
[deep learning] semantic segmentation: paper reading: (CVPR 2022) mpvit (cnn+transformer): multipath visual transformer for dense prediction

发生OOM了,你知道是什么原因吗,又该怎么解决呢?
![[deep learning] semantic segmentation: thesis reading (neurips 2021) maskformer: per pixel classification is not all you need](/img/84/cfcd006d445fc54ea0eda3f92e7d9d.jpg)
[deep learning] semantic segmentation: thesis reading (neurips 2021) maskformer: per pixel classification is not all you need

MapReduce instance (V): secondary sorting

Oom happened. Do you know the reason and how to solve it?
随机推荐
Regular expressions are actually very simple
【深度学习】语义分割:论文阅读:(2021-12)Mask2Former
[deep learning] semantic segmentation: paper reading: (CVPR 2022) mpvit (cnn+transformer): multipath visual transformer for dense prediction
Mapreduce实例(五):二次排序
Embedded development is much more difficult than MCU? Talk about SCM and embedded development and design experience
[deep learning] semantic segmentation - source code summary
May brush question 03 - sorting
为什么大学单片机课上51+汇编,为什么不直接来STM32
tn-c为何不可用2p断路器?
四川云教和双师模式
[untitled]
Libuv thread
大学想要选择学习自动化专业,可以看什么书去提前了解?
Nc29 search in two-dimensional array
[Chongqing Guangdong education] reference materials for nine lectures on the essence of Marxist Philosophy in Wuhan University
学习单片机对社会的帮助是很大的
Some thoughts on the study of 51 single chip microcomputer
CAPL 脚本对.ini 配置文件的高阶操作
Summary of May training - from a Guang
Download address of canoe, download and activation of can demo 16, and appendix of all canoe software versions