1 Star 0 Fork 15

张尧/pkgship

forked from src-openEuler/pkgship 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0004-wrong-judgment-of-startup-success.patch 2.02 KB
一键复制 编辑 原始数据 按行查看 历史
LiHeavy 提交于 2021-03-20 00:18 . update patchs
--- a/packageship/pkgshipd
+++ b/packageship/pkgshipd
@@ -3,7 +3,7 @@ SYS_PATH=/etc/pkgship
OUT_PATH=/opt/pkgship/uwsgi
OPERATION=$1
PKGSHIP_CONSTANT="pkgship"
-MEM_THRESHOLD='700'
+MEM_THRESHOLD='2048'
MEM_FREE=$(free -m | grep "Mem" | awk '{print $7}')
function check_user() {
@@ -262,22 +262,34 @@ function uwsgi_log_logrotate() {
echo "[INFO] Start the logrotate task success"
}
+function is_started() {
+ pkgship_version=$(pkgship -v)
+ if [[ -n ${pkgship_version} ]] && [[ ${pkgship_version} =~ "Version" ]]; then
+ return 0
+ else
+ return 1
+ fi
+}
+
function start_service() {
- uwsgi_pid=$(ps -ef | grep -v grep | grep "uwsgi" | grep "${PKGSHIP_CONSTANT}.ini" | awk '{print $2}')
- if [ -n "${uwsgi_pid}" ]; then
+ if is_started; then
echo "[ERROR] ${PKGSHIP_CONSTANT} service is running, please stop it first."
exit 1
else
uwsgi -d --ini $OUT_PATH/${PKGSHIP_CONSTANT}.ini
echo "[INFO] START uwsgi service: ${PKGSHIP_CONSTANT}.ini"
- uwsgi_pid=$(ps -ef | grep -v grep | grep "uwsgi" | grep "${PKGSHIP_CONSTANT}.ini" | awk '{print $2}')
- if [ -z "${uwsgi_pid}" ]; then
- echo "[ERROR] Service failed to start, please check log $(get_config "daemonize")"
- exit 1
- fi
- uwsgi_log_logrotate
- echo "[INFO] Start pkgship service success!!!"
- exit 0
+
+ for i in {1..5}; do
+ if is_started; then
+ uwsgi_log_logrotate
+ echo "[INFO] Start pkgship service success!!!"
+ exit 0
+ fi
+ sleep 2s
+ done
+
+ echo "[ERROR] Service failed to start, please check log $(get_config "daemonize")"
+ exit 1
fi
}
@@ -288,8 +300,7 @@ function stop_service() {
exit 1
fi
- uwsgi_pid=$(ps -ef | grep -v grep | grep "uwsgi" | grep "${PKGSHIP_CONSTANT}.ini" | awk '{print $2}')
- if [ -n "${uwsgi_pid}" ]; then
+ if is_started; then
uwsgi --stop $OUT_PATH/${PKGSHIP_CONSTANT}.pid
echo "[INFO] STOP uwsgi service: $OUT_PATH/${PKGSHIP_CONSTANT}.ini"
echo "[INFO] The run log is saved into: $(get_config "daemonize")"
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/polite2anyone/pkgship.git
[email protected]:polite2anyone/pkgship.git
polite2anyone
pkgship
pkgship
master

搜索帮助