当前位置:网站首页>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 $*
边栏推荐
- 五月刷题26——并查集
- Mexican SQL manual injection vulnerability test (mongodb database) problem solution
- 33岁可以学PLC吗
- 在CANoe中通过Panel面板控制Test Module 运行(初级)
- Can I learn PLC at the age of 33
- cmooc互联网+教育
- May brush question 02 - string
- Interview shock 62: what are the precautions for group by?
- [deep learning] semantic segmentation: thesis reading (neurips 2021) maskformer: per pixel classification is not all you need
- May brush question 01 - array
猜你喜欢
Control the operation of the test module through the panel in canoe (primary)
MapReduce instance (x): chainmapreduce
《ASP.NET Core 6框架揭秘》样章发布[200页/5章]
Mexican SQL manual injection vulnerability test (mongodb database) problem solution
宝塔的安装和flask项目部署
[one click] it only takes 30s to build a blog with one click - QT graphical tool
How can I take a shortcut to learn C language in college
如何让shell脚本变成可执行文件
51单片机进修的一些感悟
Take you back to spark ecosystem!
随机推荐
CANoe仿真功能之自动化序列(Automation Sequences )
I2C summary (single host and multi host)
CAPL 脚本对.ini 配置文件的高阶操作
Several ways of MySQL database optimization (pen interview must ask)
What are the models of data modeling
Cooperative development in embedded -- function pointer
CAPL script printing functions write, writeex, writelineex, writetolog, writetologex, writedbglevel do you really know which one to use under what circumstances?
018. Valid palindromes
MapReduce instance (IX): reduce end join
VH6501学习系列文章
June brush question 01 - array
Summary of May training - from a Guang
If a university wants to choose to study automation, what books can it read in advance?
Hero League rotation map automatic rotation
Programmation défensive en langage C dans le développement intégré
听哥一句劝,按这套嵌入式的课程内容和课程体系去学习
Why data Tiering
Tianmu MVC audit I
单片机如何从上电复位执行到main函数?
Defensive C language programming in embedded development