mirror of
https://github.com/crawlab-team/crawlab.git
synced 2026-01-25 17:42:25 +01:00
@@ -368,6 +368,8 @@ func InitSpiderService() error {
|
||||
}
|
||||
}
|
||||
|
||||
// 发布所有爬虫
|
||||
PublishAllSpiders()
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"crawlab/database"
|
||||
"crawlab/model"
|
||||
"crawlab/utils"
|
||||
"fmt"
|
||||
"github.com/apex/log"
|
||||
"github.com/globalsign/mgo/bson"
|
||||
"github.com/satori/go.uuid"
|
||||
@@ -25,7 +26,7 @@ type SpiderSync struct {
|
||||
|
||||
func (s *SpiderSync) CreateMd5File(md5 string) {
|
||||
path := filepath.Join(viper.GetString("spider.path"), s.Spider.Name)
|
||||
utils.CreateFilePath(path)
|
||||
utils.CreateDirPath(path)
|
||||
|
||||
fileName := filepath.Join(path, Md5File)
|
||||
file := utils.OpenFile(fileName)
|
||||
@@ -66,10 +67,14 @@ func (s *SpiderSync) RemoveSpiderFile() {
|
||||
// 检测是否已经下载中
|
||||
func (s *SpiderSync) CheckDownLoading(spiderId string, fileId string) (bool, string) {
|
||||
key := s.GetLockDownloadKey(spiderId)
|
||||
if _, err := database.RedisClient.HGet("spider", key); err == nil {
|
||||
return true, key
|
||||
key2, err := database.RedisClient.HGet("spider", key)
|
||||
if err != nil {
|
||||
return false, key2
|
||||
}
|
||||
return false, key
|
||||
if key2 == "" {
|
||||
return false, key2
|
||||
}
|
||||
return true, key2
|
||||
}
|
||||
|
||||
// 下载爬虫
|
||||
@@ -78,6 +83,7 @@ func (s *SpiderSync) Download() {
|
||||
fileId := s.Spider.FileId.Hex()
|
||||
isDownloading, key := s.CheckDownLoading(spiderId, fileId)
|
||||
if isDownloading {
|
||||
log.Infof(fmt.Sprintf("spider is already being downloaded, spider id: %s", s.Spider.Id.Hex()))
|
||||
return
|
||||
} else {
|
||||
_ = database.RedisClient.HSet("spider", key, key)
|
||||
|
||||
@@ -55,7 +55,7 @@ func OpenFile(fileName string) *os.File {
|
||||
}
|
||||
|
||||
// 创建文件夹
|
||||
func CreateFilePath(filePath string) {
|
||||
func CreateDirPath(filePath string) {
|
||||
if !Exists(filePath) {
|
||||
if err := os.MkdirAll(filePath, os.ModePerm); err != nil {
|
||||
log.Errorf("create file error: %s, file_path: %s", err.Error(), filePath)
|
||||
|
||||
@@ -41,6 +41,13 @@
|
||||
<el-form-item prop="password" :label="$t('Password')">
|
||||
<el-input v-model="userInfo.password" type="password" :placeholder="$t('Password')"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<div style="text-align: right">
|
||||
<el-button type="success" size="small" @click="saveUserInfo">
|
||||
{{$t('Save')}}
|
||||
</el-button>
|
||||
</div>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane :label="$t('Notify Settings')" name="notify">
|
||||
@@ -77,6 +84,13 @@
|
||||
<el-input v-model="userInfo.setting.wechat_robot_webhook"
|
||||
:placeholder="$t('Wechat Robot Webhook')"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<div style="text-align: right">
|
||||
<el-button type="success" size="small" @click="saveUserInfo">
|
||||
{{$t('Save')}}
|
||||
</el-button>
|
||||
</div>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane :label="$t('Global Variable')" name="global-variable">
|
||||
@@ -199,6 +213,11 @@ export default {
|
||||
'globalVariableForm'
|
||||
])
|
||||
},
|
||||
watch: {
|
||||
userInfoStr () {
|
||||
this.saveUserInfo()
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
deleteGlobalVariableHandle (id) {
|
||||
this.$confirm(this.$t('Are you sure to delete this global variable'), this.$t('Notification'), {
|
||||
|
||||
Reference in New Issue
Block a user