fix 删除爬虫的问题

This commit is contained in:
陈景阳
2019-09-30 12:09:37 +08:00
parent d93bff63e7
commit 41556cab74
20 changed files with 240 additions and 142 deletions

View File

@@ -0,0 +1,24 @@
package msg_handler
import (
"crawlab/model"
"crawlab/utils"
"github.com/globalsign/mgo/bson"
"github.com/spf13/viper"
"path/filepath"
)
type Spider struct {
SpiderId string
}
func (s *Spider) Handle() error {
// 移除本地的爬虫目录
spider, err := model.GetSpider(bson.ObjectIdHex(s.SpiderId))
if err != nil {
return err
}
path := filepath.Join(viper.GetString("spider.path"), spider.Name)
utils.RemoveFiles(path)
return nil
}