当前位置:网站首页>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 $*
边栏推荐
- Contest3145 - the 37th game of 2021 freshman individual training match_ B: Password
- 51单片机进修的一些感悟
- 一大波开源小抄来袭
- Tianmu MVC audit I
- CANoe不能自动识别串口号?那就封装个DLL让它必须行
- Hugo blog graphical writing tool -- QT practice
- Compress decompress
- CAPL脚本中关于相对路径/绝对路径操作的几个傻傻分不清的内置函数
- Inject common SQL statement collation
- What are the models of data modeling
猜你喜欢
51单片机进修的一些感悟
MapReduce working mechanism
C杂讲 动态链表操作 再讲
Write your own CPU Chapter 10 - learning notes
How can I take a shortcut to learn C language in college
手把手教您怎么编写第一个单片机程序
Programmation défensive en langage C dans le développement intégré
嵌入式开发中的防御性C语言编程
MapReduce instance (VI): inverted index
Oom happened. Do you know the reason and how to solve it?
随机推荐
The real future of hardware engineers may not be believed by you if I say so
五月刷题03——排序
五月刷题26——并查集
五月集训总结——来自阿光
五月刷题01——数组
五月刷题27——图
CAPL 脚本打印函数 write ,writeEx ,writeLineEx ,writeToLog ,writeToLogEx ,writeDbgLevel 你真的分的清楚什么情况下用哪个吗?
六月刷题01——数组
六月刷题02——字符串
16 医疗挂号系统_【预约下单】
51单片机进修的一些感悟
五月刷题02——字符串
tn-c为何不可用2p断路器?
一大波開源小抄來襲
通过bat脚本配置系统环境变量
Why can't TN-C use 2p circuit breaker?
嵌入式开发中的防御性C语言编程
竞赛vscode配置指南
Regular expressions are actually very simple
Teach you how to write the first MCU program hand in hand