当前位置:网站首页>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 $*
边栏推荐
- Selection of software load balancing and hardware load balancing
- Popularization of security knowledge - twelve moves to protect mobile phones from network attacks
- [untitled]
- Counter attack of noodles: redis asked 52 questions in a series, with detailed pictures and pictures. Now the interview is stable
- NLP路线和资源
- MapReduce instance (VII): single table join
- Write your own CPU Chapter 10 - learning notes
- Automation sequences of canoe simulation functions
- 通过bat脚本配置系统环境变量
- 五月刷题27——图
猜你喜欢
I2C summary (single host and multi host)
MapReduce instance (x): chainmapreduce
Oom happened. Do you know the reason and how to solve it?
嵌入式开发中的防御性C语言编程
C杂讲 动态链表操作 再讲
嵌入式開發中的防禦性C語言編程
A wave of open source notebooks is coming
Keep these four requirements in mind when learning single chip microcomputer with zero foundation and avoid detours
五月集训总结——来自阿光
CAPL script pair High level operation of INI configuration file
随机推荐
MapReduce instance (x): chainmapreduce
零基础学习单片机切记这四点要求,少走弯路
MapReduce instance (VI): inverted index
Several ways of MySQL database optimization (pen interview must ask)
宝塔的安装和flask项目部署
History of object recognition
C杂讲 浅拷贝 与 深拷贝
C杂讲 文件 续讲
Defensive C language programming in embedded development
AI的路线和资源
手把手教您怎么编写第一个单片机程序
Learning SCM is of great help to society
Vh6501 Learning Series
Inject common SQL statement collation
CAPL script printing functions write, writeex, writelineex, writetolog, writetologex, writedbglevel do you really know which one to use under what circumstances?
嵌入式開發中的防禦性C語言編程
五月刷题02——字符串
The replay block of canoe still needs to be combined with CAPL script to make it clear
Mexican SQL manual injection vulnerability test (mongodb database) problem solution
MySQL ERROR 1040: Too many connections