uwsgi重啟shell指令碼

2021-09-27 06:32:56 字數 1435 閱讀 1921

根據參考鏈結,修改了部分內容(定義了變數,修復了一些bug,增加了顏色輸出)

#!/bin/bash

ini="/www/mysite1/uwsgi/uwsgi.ini"

uwsgi="/virtualenvs/venv/bin/uwsgi"

psid="ps aux | grep "uwsgi"| grep -v "grep" | wc -l"

if [ ! -n "$1"

]then

content="

usages: sh uwsgiserver.sh [start|stop|restart]

"echo -e "

\033[31m $content \033[0m

"exit 0fi

if [ $1 =start ]

then

if [ `eval $psid` -gt 4

]

then

content="

uwsgi is running!

"echo -e "

\033[32m $content \033[0m

"exit

0else

$uwsgi $ini

content="

start uwsgi service [ok]

"echo -e "

\033[32m $content \033[0m"fi

elif [ $1 = stop ];then

if [ `eval $psid` -gt 4 ];then

killall -9

uwsgi

ficontent="

stop uwsgi service [ok]

"echo -e "

\033[32m $content \033[0m

"elif [ $1 = restart ];then

if [ `eval $psid` -gt 4 ];then

killall -9

uwsgi

fi$uwsgi --ini $ini

content="

restart uwsgi service [ok]

"echo -e "

\033[32m $content \033[0m

"else

content="

usages: sh uwsgiserver.sh [start|stop|restart]

"echo -e "

\033[31m $content \033[0m

"fi

注意:請根據實際情況,修改上面2個變數,即可使用。效果如下:

shell指令碼重啟tomcat

1.新建shell空指令碼檔案,如 home tr.sh,並設定許可權 chmod 750 home tr.sh 2.設定檔案形式 sed e s m g home tr.sh home tr.sh 3.編輯指令碼 vi home tr.sh tomcat home home apache tomc...

shell指令碼實現程式重啟

最近做的ipc端hls推流不穩定偶爾要死機,而雲伺服器又希望能隨時連上ipc。在ipc端有沒有supervisor這種工具,就需要自己想下怎麼然異常退出的程式重啟起來。經過查閱網路資料,通過shell即可實現。bin sh help 引數範圍檢查 if 1 then help fi 檢查程序例項是否...

shell指令碼實現程序重啟

bin bash id ps ef grep zabbix grep v 0 grep v zabbix agentd grep v grep awk for id in id dokill 9 id done echo su zabbix 注意 1 不能使用pkill zabbix server ...