Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
openEuler-Advisor
提交
4bac19f1
O
openEuler-Advisor
项目概览
openeuler
/
openEuler-Advisor
通知
32
Star
4
Fork
4
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
openEuler-Advisor
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
4bac19f1
编写于
9月 03, 2020
作者:
O
openeuler-ci-bot
提交者:
Gitee
9月 03, 2020
浏览文件
操作
浏览文件
下载
差异文件
!123 解决脚本启动时参数校验、restart功能不能使用以及引入新包导致编译不通过的问题
Merge pull request !123 from 薄皮小笼包/master
上级
f48313d2
943b8384
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
96 addition
and
16 deletion
+96
-16
packageship/packageship/libs/log/loghelper.py
packageship/packageship/libs/log/loghelper.py
+3
-3
packageship/packageship/package.ini
packageship/packageship/package.ini
+1
-2
packageship/packageship/pkgshipd
packageship/packageship/pkgshipd
+92
-11
未找到文件。
packageship/packageship/libs/log/loghelper.py
浏览文件 @
4bac19f1
...
...
@@ -5,7 +5,7 @@ Logging related
import
os
import
pathlib
import
logging
from
concurrent_log_handler
import
Concurrent
RotatingFileHandler
from
logging.handlers
import
RotatingFileHandler
from
packageship
import
system_config
from
packageship.libs.configutils.readconfig
import
ReadConfig
...
...
@@ -44,7 +44,7 @@ def setup_log(config=None):
except
FileExistsError
:
pathlib
.
Path
(
path
).
touch
()
file_log_handler
=
Concurrent
RotatingFileHandler
(
file_log_handler
=
RotatingFileHandler
(
path
,
maxBytes
=
max_bytes
,
backupCount
=
backup_count
)
formatter
=
logging
.
Formatter
(
...
...
@@ -96,7 +96,7 @@ class Log():
self
.
max_bytes
=
314572800
def
__init_handler
(
self
):
self
.
__file_handler
=
Concurrent
RotatingFileHandler
(
self
.
__file_handler
=
RotatingFileHandler
(
self
.
__path
,
maxBytes
=
self
.
max_bytes
,
backupCount
=
self
.
backup_count
,
encoding
=
"utf-8"
)
def
__set_handler
(
self
):
...
...
packageship/packageship/package.ini
浏览文件 @
4bac19f1
...
...
@@ -55,8 +55,7 @@ buffer-size=65536
http-timeout
=
600
; Server response time
harakiri
=
600
; Allow multiple threads to run in the system
enable-threads
=
true
[TIMEDTASK]
...
...
packageship/packageship/pkgshipd
浏览文件 @
4bac19f1
...
...
@@ -10,6 +10,91 @@ if [ ! -f "$SYS_PATH/package.ini" ]; then
exit
0
fi
function
check_config_file
(){
echo
"[INFO] Check validation of config file."
check_null
echo
"[INFO] Check validation of ip addresses."
write_port
=
$(
get_config
"
$service
"
"write_port"
)
query_port
=
$(
get_config
"
$service
"
"query_port"
)
write_ip_addr
=
$(
get_config
"
$service
"
"write_ip_addr"
)
query_ip_addr
=
$(
get_config
"
$service
"
"query_ip_addr"
)
check_addr
$write_ip_addr
$write_port
check_addr
$query_ip_addr
$query_port
echo
"[INFO] IP addresses are all valid."
echo
"[INFO] Check validation of numbers."
hour
=
$(
get_config
"
$service
"
"hour"
)
minute
=
$(
get_config
"
$service
"
"minute"
)
backup_count
=
$(
get_config
"
$service
"
"backup_count"
)
max_bytes
=
$(
get_config
"
$service
"
"max_bytes"
)
check_num
$hour
"hour"
check_num
$backup_count
"backup_count"
check_num
$max_bytes
"max_bytes"
echo
"[INFO] All numbers are valid."
echo
"[INFO] Check validation of words."
log_level
=
$(
get_config
"
$service
"
"log_level"
)
open
=
$(
get_config
"
$service
"
"open"
)
check_word
$log_level
"INFO|DEBUG|WARNING|ERROR|CRITICAL"
"log_level"
check_word
$open
"True|False"
"open"
echo
"[INFO] All words are valid."
echo
"[INFO] Config file checked valid."
}
function
check_addr
(){
ip
=
$1
ret
=
1
if
[[
$ip
=
~ ^[0-9]
{
1,3
}
\.
[
0-9]
{
1,3
}
\.
[
0-9]
{
1,3
}
\.
[
0-9]
{
1,3
}
$
]]
;
then
ip
=(
${
ip
//\./
}
)
[[
${
ip
[0]
}
-le
255
&&
${
ip
[1]
}
-le
255
&&
${
ip
[2]
}
-le
255
&&
${
ip
[3]
}
-le
255
]]
ret
=
$?
fi
if
[
$ret
-ne
0
]
;
then
echo
"[ERROR] Invaild ip of
$1
"
exit
1
fi
if
[[
$2
-gt
65534
||
$2
-lt
1025
]]
;
then
echo
"[ERROR] Invalid port of
$2
"
exit
1
fi
}
function
check_null
(){
list
=
`
cat
$SYS_PATH
/package.ini |
grep
-E
^[a-z_-]+
=
|
awk
-F
'='
'{if($2 == "")print $1}'
`
num
=
0
for
val
in
$list
do
num
=
$[$num
+1]
done
if
[
$num
-gt
1
]
;
then
echo
"[ERROR] CAN NOT find all config name in:
$SYS_PATH
/package.ini, Please check the file:"
for
val
in
$list
do
echo
$val
done
exit
1
fi
}
function
check_num
(){
result
=
`
echo
$1
|
grep
'^[[:digit:]]*$'
`
if
[
$?
-ne
0
]
;
then
echo
"[ERROR]
$2
should be a number."
exit
1
fi
}
function
check_word
(){
result
=
`
echo
$1
|
grep
-E
"
$2
"
`
if
[
$?
-ne
0
]
;
then
echo
"[ERROR]
$3
should be
$2
."
exit
1
fi
}
function
get_config
(){
cat
$SYS_PATH
/package.ini |
grep
-E
^
$2
|
sed
s/[[:space:]]//g |
awk
'BEGIN{FS="="}{print $2}'
}
...
...
@@ -109,7 +194,7 @@ function stop_service(){
if
[
!
-n
"
$1
"
]
then
echo
"Usages: sh pkgshipd.sh start|stop
|restart
[manage|selfpkg]"
echo
"Usages: sh pkgshipd.sh start|stop [manage|selfpkg]"
exit
0
fi
...
...
@@ -122,6 +207,11 @@ else
exit
0
fi
if
[
$1
=
"start"
]
then
check_config_file
fi
create_config_file
$service
if
[
$?
-ne
0
]
;
then
exit
0
...
...
@@ -146,16 +236,7 @@ elif [ $1 = stop ];then
fi
echo
"===The run log is saved into:
$daemonize
==="
elif
[
$1
=
restart
]
;
then
if
[
$service
=
"all"
]
;
then
stop_service
"manage"
"reload"
stop_service
"selfpkg"
"reload"
else
stop_service
$service
"reload"
fi
echo
"===The run log is saved into:
$daemonize
==="
else
echo
"Usages: sh pkgshipd.sh start|stop
|restart
[manage|selfpkg]"
echo
"Usages: sh pkgshipd.sh start|stop [manage|selfpkg]"
fi
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录