当前位置:网站首页>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 $*
边栏推荐
- What are the models of data modeling
- 如何让shell脚本变成可执行文件
- Upload vulnerability
- History of object recognition
- 一大波开源小抄来袭
- 嵌入式开发中的防御性C语言编程
- 51单片机进修的一些感悟
- MapReduce instance (V): secondary sorting
- Hugo blog graphical writing tool -- QT practice
- How does the single chip microcomputer execute the main function from power on reset?
猜你喜欢

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

Hero League rotation map automatic rotation

嵌入式开发中的防御性C语言编程

A wave of open source notebooks is coming

Combined search /dfs solution - leetcode daily question - number of 1020 enclaves

Embedded development is much more difficult than MCU? Talk about SCM and embedded development and design experience

Redis distributed lock implementation redison 15 questions

Counter attack of noodles: redis asked 52 questions in a series, with detailed pictures and pictures. Now the interview is stable

AI的路线和资源

max-flow min-cut
随机推荐
Contest3145 - the 37th game of 2021 freshman individual training match_ B: Password
[flask] crud addition and query operation of data
Learning SCM is of great help to society
C杂讲 文件 初讲
Take you back to spark ecosystem!
A wave of open source notebooks is coming
CAPL脚本中关于相对路径/绝对路径操作的几个傻傻分不清的内置函数
Write your own CPU Chapter 10 - learning notes
嵌入式开发中的防御性C语言编程
MapReduce instance (IX): reduce end join
硬件工程师的真实前途我说出来可能你们不信
Automation sequences of canoe simulation functions
Embedded development is much more difficult than MCU? Talk about SCM and embedded development and design experience
Une grande vague d'attaques à la source ouverte
Safety notes
51单片机进修的一些感悟
嵌入式开发比单片机要难很多?谈谈单片机和嵌入式开发设计经历
Control the operation of the test module through the panel in canoe (Advanced)
June brush question 02 - string
Why is 51+ assembly in college SCM class? Why not come directly to STM32