当前位置:网站首页>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 $*
边栏推荐
- Pointer learning
- Popularization of security knowledge - twelve moves to protect mobile phones from network attacks
- Combined search /dfs solution - leetcode daily question - number of 1020 enclaves
- Mexican SQL manual injection vulnerability test (mongodb database) problem solution
- CANoe CAPL文件操作目录合集
- May brush question 02 - string
- MapReduce instance (V): secondary sorting
- Cap theory
- CAPL 脚本打印函数 write ,writeEx ,writeLineEx ,writeToLog ,writeToLogEx ,writeDbgLevel 你真的分的清楚什么情况下用哪个吗?
- Interview shock 62: what are the precautions for group by?
猜你喜欢
Carolyn Rosé博士的社交互通演讲记录
四川云教和双师模式
CAPL 脚本打印函数 write ,writeEx ,writeLineEx ,writeToLog ,writeToLogEx ,writeDbgLevel 你真的分的清楚什么情况下用哪个吗?
面试突击62:group by 有哪些注意事项?
Programmation défensive en langage C dans le développement intégré
在CANoe中通過Panel面板控制Test Module 運行(初級)
17 医疗挂号系统_【微信支付】
51单片机进修的一些感悟
嵌入式开发比单片机要难很多?谈谈单片机和嵌入式开发设计经历
[flask] crud addition and query operation of data
随机推荐
What are the models of data modeling
大学想要选择学习自动化专业,可以看什么书去提前了解?
Several silly built-in functions about relative path / absolute path operation in CAPL script
华南技术栈CNN+Bilstm+Attention
tn-c为何不可用2p断路器?
MySQL ERROR 1040: Too many connections
VH6501学习系列文章
Teach you how to write the first MCU program hand in hand
C杂讲 文件 续讲
17 医疗挂号系统_【微信支付】
CAPL script printing functions write, writeex, writelineex, writetolog, writetologex, writedbglevel do you really know which one to use under what circumstances?
Control the operation of the test module through the panel in canoe (primary)
大学C语言入门到底怎么学才可以走捷径
Hero League rotation map automatic rotation
A new understanding of RMAN retention policy recovery window
16 医疗挂号系统_【预约下单】
CAPL 脚本对.ini 配置文件的高阶操作
Upload vulnerability
Inject common SQL statement collation
通过bat脚本配置系统环境变量