Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
易企天创
zentaoatf
提交
a73c0964
Z
zentaoatf
项目概览
易企天创
/
zentaoatf
大约 1 年 前同步成功
通知
11
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
3
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Z
zentaoatf
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
3
Issue
3
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a73c0964
编写于
12月 21, 2020
作者:
aaronchen2k2k
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
agent features
上级
7fd93152
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
172 addition
and
6 deletion
+172
-6
Makefile
Makefile
+25
-0
src/server/server.go
src/server/server.go
+35
-5
src/server/service/config.go
src/server/service/config.go
+73
-0
src/server/service/task.go
src/server/service/task.go
+14
-0
src/server/utils/common/bak.go
src/server/utils/common/bak.go
+25
-1
未找到文件。
Makefile
0 → 100644
浏览文件 @
a73c0964
VERSION
=
2.0
PROJECT
=
ztf
QINIU_DIR
=
/Users/aaron/work/zentao/qiniu/
QINIU_DIST_DIR
=
${QINIU_DIR}${PROJECT}
/
${VERSION}
/
PACKAGE
=
${PROJECT}
-
${VERSION}
BINARY
=
zd
BIN_DIR
=
bin
BIN_ZIP_DIR
=
${BIN_DIR}
/zip/
${PROJECT}
/
${VERSION}
/
BIN_OUT
=
${BIN_DIR}
/
${PROJECT}
/
${VERSION}
/
BIN_WIN64
=
${BIN_OUT}
win64/zd/
BIN_WIN32
=
${BIN_OUT}
win32/zd/
BIN_LINUX
=
${BIN_OUT}
linux/zd/
BIN_MAC
=
${BIN_OUT}
mac/zd/
default
:
gen_version_file upload_to
gen_version_file
:
@
echo
'gen version'
@
mkdir
-p
${QINIU_DIR}
/
${PROJECT}
/
@
echo
${VERSION}
>
${QINIU_DIR}
/
${PROJECT}
/version.txt
upload_to
:
@
echo
'upload...'
@
find
${QINIU_DIR}
-name
".DS_Store"
-type
f
-delete
@
qshell qupload2
--src-dir
=
${QINIU_DIR}
--bucket
=
download
--thread-count
=
10
--log-file
=
qshell.log
--rescan-local
--overwrite
src/server/server.go
浏览文件 @
a73c0964
...
...
@@ -14,10 +14,13 @@ import (
"io"
"io/ioutil"
"net/http"
"os"
"strconv"
)
type
Server
struct
{
commonService
*
service
.
CommonService
configService
*
service
.
ConfigService
agentService
*
service
.
AgentService
buildService
*
service
.
BuildService
taskService
*
service
.
TaskService
...
...
@@ -26,6 +29,7 @@ type Server struct {
func
NewServer
()
*
Server
{
commonService
:=
service
.
NewCommonService
()
configService
:=
service
.
NewConfigService
()
agentService
:=
service
.
NewAgentService
()
heartBeatService
:=
service
.
NewHeartBeatService
()
...
...
@@ -36,7 +40,7 @@ func NewServer() *Server {
cronService
:=
cron
.
NewCronService
(
heartBeatService
,
buildService
,
taskService
,
execService
)
cronService
.
Init
()
return
&
Server
{
commonService
:
commonService
,
agentService
:
agentService
,
return
&
Server
{
commonService
:
commonService
,
configService
:
configService
,
agentService
:
agentService
,
buildService
:
buildService
,
taskService
:
taskService
,
cronService
:
cronService
}
}
...
...
@@ -76,7 +80,7 @@ func (s *Server) handle(writer http.ResponseWriter, req *http.Request) {
serverUtils
.
SetupCORS
(
&
writer
,
req
)
if
req
.
Method
==
"GET"
{
resp
,
err
=
s
.
get
(
req
)
resp
,
err
=
s
.
get
(
writer
,
req
)
if
err
!=
nil
{
serverUtils
.
OutputErr
(
err
,
writer
)
return
...
...
@@ -94,9 +98,9 @@ func (s *Server) handle(writer http.ResponseWriter, req *http.Request) {
io
.
WriteString
(
writer
,
string
(
bytes
))
}
func
(
s
*
Server
)
get
(
req
*
http
.
Request
)
(
resp
domain
.
RespData
,
err
error
)
{
func
(
s
*
Server
)
get
(
writer
http
.
ResponseWriter
,
req
*
http
.
Request
)
(
resp
domain
.
RespData
,
err
error
)
{
resp
=
domain
.
RespData
{
Code
:
1
,
Msg
:
"success"
}
method
,
_
:=
serverUtils
.
ParserGetParams
(
req
)
method
,
params
:=
serverUtils
.
ParserGetParams
(
req
)
switch
method
{
...
...
@@ -104,7 +108,10 @@ func (s *Server) get(req *http.Request) (resp domain.RespData, err error) {
resp
.
Data
=
s
.
taskService
.
ListTask
()
case
"listHistory"
:
resp
.
Msg
=
"listHistory"
resp
.
Data
=
s
.
taskService
.
ListHistory
()
case
"down"
:
Download
(
writer
,
params
[
"f"
])
case
""
:
resp
.
Code
=
0
...
...
@@ -141,6 +148,9 @@ func (s *Server) post(req *http.Request) (resp domain.RespData, err error) {
case
"addTask"
:
s
.
buildService
.
Add
(
reqData
)
case
"config"
:
s
.
configService
.
Update
(
reqData
)
default
:
resp
.
Code
=
0
resp
.
Msg
=
"API NOT FOUND"
...
...
@@ -152,3 +162,23 @@ func (s *Server) post(req *http.Request) (resp domain.RespData, err error) {
return
}
func
Download
(
w
http
.
ResponseWriter
,
fi
string
)
{
logDir
:=
vari
.
ZTFDir
+
"log-agent"
+
constant
.
PthSep
file
,
_
:=
os
.
Open
(
logDir
+
fi
)
defer
file
.
Close
()
fileHeader
:=
make
([]
byte
,
512
)
file
.
Read
(
fileHeader
)
fileStat
,
_
:=
file
.
Stat
()
w
.
Header
()
.
Set
(
"Content-Disposition"
,
"attachment; filename="
+
fi
)
w
.
Header
()
.
Set
(
"Content-Type"
,
http
.
DetectContentType
(
fileHeader
))
w
.
Header
()
.
Set
(
"Content-Length"
,
strconv
.
FormatInt
(
fileStat
.
Size
(),
10
))
file
.
Seek
(
0
,
0
)
io
.
Copy
(
w
,
file
)
return
}
src/server/service/config.go
0 → 100644
浏览文件 @
a73c0964
package
service
import
(
"encoding/json"
"fmt"
"github.com/easysoft/zentaoatf/src/model"
"github.com/easysoft/zentaoatf/src/server/domain"
configUtils
"github.com/easysoft/zentaoatf/src/utils/config"
logUtils
"github.com/easysoft/zentaoatf/src/utils/log"
"github.com/easysoft/zentaoatf/src/utils/vari"
)
var
()
type
ConfigService
struct
{
}
func
NewConfigService
()
*
ConfigService
{
return
&
ConfigService
{}
}
func
(
s
*
ConfigService
)
Update
(
req
domain
.
ReqData
)
{
conf
:=
model
.
Config
{}
reqStr
,
_
:=
json
.
Marshal
(
req
.
Data
)
err
:=
json
.
Unmarshal
(
reqStr
,
&
conf
)
if
err
!=
nil
{
logUtils
.
PrintTo
(
fmt
.
Sprintf
(
"error: %v"
,
err
))
return
}
if
conf
.
Version
!=
0
{
vari
.
Config
.
Version
=
conf
.
Version
}
if
conf
.
Language
!=
""
{
vari
.
Config
.
Language
=
conf
.
Language
}
if
conf
.
Url
!=
""
{
vari
.
Config
.
Url
=
conf
.
Url
}
if
conf
.
Account
!=
""
{
vari
.
Config
.
Account
=
conf
.
Account
}
if
conf
.
Password
!=
""
{
vari
.
Config
.
Password
=
conf
.
Password
}
if
conf
.
Javascript
!=
""
{
vari
.
Config
.
Javascript
=
conf
.
Javascript
}
if
conf
.
Lua
!=
""
{
vari
.
Config
.
Lua
=
conf
.
Lua
}
if
conf
.
Perl
!=
""
{
vari
.
Config
.
Perl
=
conf
.
Perl
}
if
conf
.
Php
!=
""
{
vari
.
Config
.
Php
=
conf
.
Php
}
if
conf
.
Python
!=
""
{
vari
.
Config
.
Python
=
conf
.
Python
}
if
conf
.
Ruby
!=
""
{
vari
.
Config
.
Ruby
=
conf
.
Ruby
}
if
conf
.
Tcl
!=
""
{
vari
.
Config
.
Tcl
=
conf
.
Tcl
}
if
conf
.
Lua
!=
""
{
vari
.
Config
.
Autoit
=
conf
.
Autoit
}
configUtils
.
SaveConfig
(
vari
.
Config
)
}
src/server/service/task.go
浏览文件 @
a73c0964
package
service
import
(
"fmt"
"github.com/easysoft/zentaoatf/src/server/domain"
serverUtils
"github.com/easysoft/zentaoatf/src/server/utils/common"
serverConst
"github.com/easysoft/zentaoatf/src/server/utils/const"
"github.com/easysoft/zentaoatf/src/utils/vari"
"strconv"
"time"
)
...
...
@@ -62,3 +66,13 @@ func (s *TaskService) ListTask() (data []domain.Build) {
data
=
tasks
return
}
func
(
s
*
TaskService
)
ListHistory
()
(
data
[]
map
[
string
]
string
)
{
data
=
serverUtils
.
ListHistoryLog
()
for
key
,
item
:=
range
data
{
data
[
key
][
"url"
]
=
fmt
.
Sprintf
(
"http://%s:%s/down?f=%s"
,
vari
.
IP
,
strconv
.
Itoa
(
vari
.
Port
),
item
[
"name"
])
}
return
}
src/server/utils/common/bak.go
浏览文件 @
a73c0964
...
...
@@ -8,6 +8,7 @@ import (
logUtils
"github.com/easysoft/zentaoatf/src/utils/log"
"github.com/easysoft/zentaoatf/src/utils/vari"
"io/ioutil"
"path"
"time"
)
...
...
@@ -15,7 +16,7 @@ func BakLog(src string) {
now
:=
time
.
Now
()
dateStr
:=
dateUtils
.
DateStr
(
now
)
timeStr
:=
dateUtils
.
TimeStr
(
now
)
logDir
:=
vari
.
ServerWork
Dir
+
"log-agent"
+
constant
.
PthSep
logDir
:=
vari
.
ZTF
Dir
+
"log-agent"
+
constant
.
PthSep
dateDir
:=
logDir
+
dateStr
+
constant
.
PthSep
dist
:=
dateDir
+
timeStr
+
".zip"
...
...
@@ -42,3 +43,26 @@ func removeHistoryLog(dir string) {
}
}
}
func
ListHistoryLog
()
(
ret
[]
map
[
string
]
string
)
{
logDir
:=
vari
.
ServerWorkDir
+
"log-agent"
+
constant
.
PthSep
dirs
,
_
:=
ioutil
.
ReadDir
(
logDir
)
for
_
,
dir
:=
range
dirs
{
dirName
:=
dir
.
Name
()
files
,
_
:=
ioutil
.
ReadDir
(
logDir
+
dirName
)
for
_
,
fi
:=
range
files
{
name
:=
fi
.
Name
()
if
path
.
Ext
(
name
)
!=
".zip"
{
continue
}
item
:=
map
[
string
]
string
{
"name"
:
dirName
+
constant
.
PthSep
+
name
}
ret
=
append
(
ret
,
item
)
}
}
return
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录