Merge pull request #377 from crawlab-team/develop

Develop
This commit is contained in:
Marvin Zhang
2019-12-19 10:47:17 +08:00
committed by GitHub
4 changed files with 35 additions and 14 deletions

View File

@@ -61,10 +61,36 @@ func InitMongo() error {
dialInfo.Password = mongoPassword
dialInfo.Source = mongoAuth
}
sess, err := mgo.DialWithInfo(&dialInfo)
if err != nil {
return err
// mongo session
var sess *mgo.Session
// 错误次数
errNum := 0
// 重复尝试连接mongo
for {
var err error
// 连接mongo
sess, err = mgo.DialWithInfo(&dialInfo)
if err != nil {
// 如果连接错误休息1秒错误次数+1
time.Sleep(1 * time.Second)
errNum++
// 如果错误次数超过30返回错误
if errNum >= 30 {
return err
}
} else {
// 如果没有错误,退出循环
break
}
}
// 赋值给全局mongo session
Session = sess
}
return nil

View File

@@ -55,7 +55,7 @@ func GetCurrentNode() (Node, error) {
for {
// 如果错误次数超过10次
if errNum >= 10 {
panic("cannot get current node")
return node, errors.New("cannot get current node")
}
// 尝试获取节点

View File

@@ -22,10 +22,5 @@ fi
# start nginx
service nginx start
# wait for mongo service to be ready
#/app/wait-for-it.sh $CRAWLAB_MONGO_HOST:$CRAWLAB_MONGO_PORT
# wait for redis service to be ready
#/app/wait-for-it.sh $CRAWLAB_REDIS_ADDRESS:$CRAWLAB_REDIS_PORT
# start backend
crawlab

View File

@@ -819,12 +819,12 @@ ${f.css || f.xpath} ${f.attr ? ('(' + f.attr + ')') : ''} ${f.next_stage ? (' --
},
onCheckIsList (value, stage) {
if (value) {
this.$st('爬虫详情', '配置', '勾选列表页')
this.$st.sendEv('爬虫详情', '配置', '勾选列表页')
if (!stage.list_css && !stage.list_xpath) {
stage.list_xpath = '//body'
}
} else {
this.$st('爬虫详情', '配置', '取消勾选列表页')
this.$st.sendEv('爬虫详情', '配置', '取消勾选列表页')
stage.list_css = ''
stage.list_xpath = ''
}
@@ -846,12 +846,12 @@ ${f.css || f.xpath} ${f.attr ? ('(' + f.attr + ')') : ''} ${f.next_stage ? (' --
},
onCheckIsPage (value, stage) {
if (value) {
this.$st('爬虫详情', '配置', '勾选分页')
this.$st.sendEv('爬虫详情', '配置', '勾选分页')
if (!stage.page_css && !stage.page_xpath) {
stage.page_xpath = '//body'
}
} else {
this.$st('爬虫详情', '配置', '取消勾选分页')
this.$st.sendEv('爬虫详情', '配置', '取消勾选分页')
stage.page_css = ''
stage.page_xpath = ''
}