Skip to content

Commit dcb9351

Browse files
authored
Merge pull request #818 from crawlab-team/develop
Develop
2 parents aabedb1 + 4991141 commit dcb9351

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+869
-205
lines changed

CHANGELOG-zh.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
# 0.5.1 (2020-07-31)
2+
### 功能 / 优化
3+
- **加入错误详情信息**.
4+
- **加入 Golang 编程语言支持**.
5+
- **加入 Chrome Driver 和 Firefox 的 Web Driver 安装脚本**.
6+
- **支持系统任务**. "系统任务"跟普通爬虫任务相似,允许用户查看诸如安装语言之类的任务日志.
7+
- **将安装语言从 RPC 更改为系统任务**.
8+
9+
### Bug 修复
10+
- **修复在爬虫市场中第一次下载爬虫时会报500错误**. [#808](https://github.com/crawlab-team/crawlab/issues/808)
11+
- **修复一部分翻译问题**.
12+
- **修复任务详情 500 错误**. [#810](https://github.com/crawlab-team/crawlab/issues/810)
13+
- **修复密码重置问题**. [#811](https://github.com/crawlab-team/crawlab/issues/811)
14+
- **修复无法下载 CSV 问题**. [#812](https://github.com/crawlab-team/crawlab/issues/812)
15+
- **修复无法安装 Node.js 问题**. [#813](https://github.com/crawlab-team/crawlab/issues/813)
16+
- **修复批量添加定时任务时默认为禁用问题**. [#814](https://github.com/crawlab-team/crawlab/issues/814)
17+
118
# 0.5.0 (2020-07-19)
219
### 功能 / 优化
320
- **爬虫市场**. 允许用户下载开源爬虫到 Crawlab.

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
# 0.5.1 (2020-07-31)
2+
### Features / Enhancement
3+
- **Added error message details**.
4+
- **Added Golang programming language support**.
5+
- **Added web driver installation scripts for Chrome Driver and Firefox**.
6+
- **Support system tasks**. A "system task" is similar to normal spider task, it allows users to view logs of general tasks such as installing languages.
7+
- **Changed methods of installing languages from RPC to system tasks**.
8+
9+
### Bug Fixes
10+
- **Fixed first download repo 500 error in Spider Market page**. [#808](https://github.com/crawlab-team/crawlab/issues/808)
11+
- **Fixed some translation issues**.
12+
- **Fixed 500 error in task detail page**. [#810](https://github.com/crawlab-team/crawlab/issues/810)
13+
- **Fixed password reset issue**. [#811](https://github.com/crawlab-team/crawlab/issues/811)
14+
- **Fixed unable to download CSV issue**. [#812](https://github.com/crawlab-team/crawlab/issues/812)
15+
- **Fixed unable to install node.js issue**. [#813](https://github.com/crawlab-team/crawlab/issues/813)
16+
- **Fixed disabled status for batch adding schedules**. [#814](https://github.com/crawlab-team/crawlab/issues/814)
17+
118
# 0.5.0 (2020-07-19)
219
### Features / Enhancement
320
- **Spider Market**. Allow users to download open-source spiders into Crawlab.

backend/conf/config.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,14 @@ server:
3333
java: "N"
3434
dotnet: "N"
3535
php: "N"
36+
scripts: "/app/backend/scripts"
3637
spider:
3738
path: "/app/spiders"
3839
task:
3940
workers: 16
4041
other:
4142
tmppath: "/tmp"
42-
version: 0.5.0
43+
version: 0.5.1
4344
setting:
4445
crawlabLogToES: "N" # Send crawlab runtime log to ES, open this option "Y", remember to set esClient
4546
crawlabLogIndex: "crawlab-log"

backend/constants/system.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,8 @@ const (
1818
InstallStatusInstallingOther = "installing-other"
1919
InstallStatusInstalled = "installed"
2020
)
21+
22+
const (
23+
LangTypeLang = "lang"
24+
LangTypeWebDriver = "webdriver"
25+
)

backend/constants/task.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,8 @@ const (
2525
RunTypeRandom string = "random"
2626
RunTypeSelectedNodes string = "selected-nodes"
2727
)
28+
29+
const (
30+
TaskTypeSpider string = "spider"
31+
TaskTypeSystem string = "system"
32+
)

backend/entity/system.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ type Lang struct {
2424
InstallStatus string `json:"install_status"`
2525
DepFileName string `json:"dep_file_name"`
2626
InstallDepArgs string `json:"install_dep_cmd"`
27+
Type string `json:"type"`
2728
}
2829

2930
type Dependency struct {

backend/main.go

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,11 @@ func main() {
254254
authGroup.POST("/tasks-cancel", routes.CancelSelectedTask) // 批量取消任务
255255
authGroup.POST("/tasks-restart", routes.RestartSelectedTask) // 批量重试任务
256256
}
257+
// 系统任务/脚本
258+
{
259+
authGroup.PUT("/system-tasks", routes.PutSystemTask) // 运行系统任务
260+
authGroup.GET("/system-scripts", routes.GetSystemScripts) // 获取系统脚本列表
261+
}
257262
// 定时任务
258263
{
259264
authGroup.GET("/schedules", routes.GetScheduleList) // 定时任务列表
@@ -269,13 +274,14 @@ func main() {
269274
}
270275
// 用户
271276
{
272-
authGroup.GET("/users", routes.GetUserList) // 用户列表
273-
authGroup.GET("/users/:id", routes.GetUser) // 用户详情
274-
authGroup.POST("/users/:id", routes.PostUser) // 更改用户
275-
authGroup.DELETE("/users/:id", routes.DeleteUser) // 删除用户
276-
authGroup.PUT("/users-add", routes.PutUser) // 添加用户
277-
authGroup.GET("/me", routes.GetMe) // 获取自己账户
278-
authGroup.POST("/me", routes.PostMe) // 修改自己账户
277+
authGroup.GET("/users", routes.GetUserList) // 用户列表
278+
authGroup.GET("/users/:id", routes.GetUser) // 用户详情
279+
authGroup.POST("/users/:id", routes.PostUser) // 更改用户
280+
authGroup.DELETE("/users/:id", routes.DeleteUser) // 删除用户
281+
authGroup.PUT("/users-add", routes.PutUser) // 添加用户
282+
authGroup.GET("/me", routes.GetMe) // 获取自己账户
283+
authGroup.POST("/me", routes.PostMe) // 修改自己账户
284+
authGroup.POST("/me/change-password", routes.PostMeChangePassword) // 修改自己密码
279285
}
280286
// 系统
281287
{

backend/model/schedule.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,10 @@ func GetScheduleList(filter interface{}) ([]Schedule, error) {
6969
if schedule.RunType == constants.RunTypeSelectedNodes {
7070
for _, nodeId := range schedule.NodeIds {
7171
// 选择单一节点
72-
node, _ := GetNode(nodeId)
72+
node, err := GetNode(nodeId)
73+
if err != nil {
74+
continue
75+
}
7376
schedule.Nodes = append(schedule.Nodes, node)
7477
}
7578
}

backend/model/task.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"crawlab/database"
66
"crawlab/utils"
77
"github.com/apex/log"
8+
"github.com/globalsign/mgo"
89
"github.com/globalsign/mgo/bson"
910
"runtime/debug"
1011
"time"
@@ -29,6 +30,7 @@ type Task struct {
2930
Pid int `json:"pid" bson:"pid"`
3031
RunType string `json:"run_type" bson:"run_type"`
3132
ScheduleId bson.ObjectId `json:"schedule_id" bson:"schedule_id"`
33+
Type string `json:"type" bson:"type"`
3234

3335
// 前端数据
3436
SpiderName string `json:"spider_name"`
@@ -514,3 +516,19 @@ func UpdateTaskErrorLogs(taskId string, errorRegexPattern string) error {
514516

515517
return nil
516518
}
519+
520+
func GetTaskByFilter(filter bson.M) (t Task, err error) {
521+
s, c := database.GetCol("tasks")
522+
defer s.Close()
523+
524+
if err := c.Find(filter).One(&t); err != nil {
525+
if err != mgo.ErrNotFound {
526+
log.Errorf("find task by filter error: " + err.Error())
527+
debug.PrintStack()
528+
return t, err
529+
}
530+
return t, err
531+
}
532+
533+
return t, nil
534+
}

backend/routes/schedule.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,9 @@ func PutBatchSchedules(c *gin.Context) {
242242
// 添加 UserID
243243
s.UserId = services.GetCurrentUserId(c)
244244

245+
// 默认启用
246+
s.Enabled = true
247+
245248
// 添加定时任务
246249
if err := model.AddSchedule(s); err != nil {
247250
log.Errorf("add schedule error: " + err.Error())

0 commit comments

Comments
 (0)