Documentation
¶
Index ¶
- Variables
- func AddGitCronJob(s model.Spider) func()
- func AddScheduleTask(s model.Schedule) func()
- func AddTask(t model.Task) (string, error)
- func AssignTask(task model.Task) error
- func CancelSpider(id string) error
- func CancelTask(id string) (err error)
- func CheckToken(tokenStr string) (user model.User, err error)
- func CopySpider(spider model.Spider, newName string) error
- func CreateNewUser(username string, password string, role string, email string, uid bson.ObjectId) error
- func CreateResultsIndexes(col string)
- func CreateScrapyProject(s model.Spider) (err error)
- func CreateScrapySpider(s model.Spider, name string, domain string, template string) (err error)
- func DeleteLogPeriodically()
- func DownloadRepo(fullName string, userId bson.ObjectId) (err error)
- func ExecuteShellCmd(cmdStr string, cwd string, t model.Task, s model.Spider, u model.User) (err error)
- func ExecuteTask(id int)
- func FetchPythonDepInfo(depName string) (entity.Dependency, error)
- func FetchPythonDepList() ([]string, error)
- func FinishOrCancelTask(ch chan string, cmd *exec.Cmd, s model.Spider, t model.Task)
- func FinishUpTask(s model.Spider, t model.Task)
- func GenerateConfigSpiderFiles(spider model.Spider, configData entity.ConfigSpiderData) error
- func GenerateSpiderfileFromConfigData(spider model.Spider, configData entity.ConfigSpiderData) error
- func GetAdminUser() (user *model.User, err error)
- func GetAuthQuery(query bson.M, c *gin.Context) bson.M
- func GetCurrentUser(c *gin.Context) *model.User
- func GetCurrentUserId(c *gin.Context) bson.ObjectId
- func GetDocs() (data string, err error)
- func GetExecuteTaskFunc(id int) func()
- func GetFileNodeTree(dstPath string, level int) (f model.File, err error)
- func GetGitHeadHash(repo *git.Repository) string
- func GetGitRemoteBranchesPlain(gitUrl string, username string, password string) (branches []string, err error)
- func GetGitSshPublicKey() string
- func GetLangInstallStatus(nodeId string, lang entity.Lang) (string, error)
- func GetLangList(nodeId string) []entity.Lang
- func GetLatestRelease() (release entity.Release, err error)
- func GetNodejsDepList(nodeId string, searchDepName string) (depList []entity.Dependency, err error)
- func GetPythonDepList(nodeId string, searchDepName string) ([]entity.Dependency, error)
- func GetPythonDepListFromRedis() ([]string, error)
- func GetPythonDepListWithInfo(depList []entity.Dependency) ([]entity.Dependency, error)
- func GetScrapyItems(s model.Spider) (res []map[string]interface{}, err error)
- func GetScrapyPipelines(s model.Spider) (res []string, err error)
- func GetScrapySettings(s model.Spider) (res []map[string]interface{}, err error)
- func GetScrapySpiderFilepath(s model.Spider, spiderName string) (res string, err error)
- func GetScrapySpiderNames(s model.Spider) ([]string, error)
- func GetSystemInfo(nodeId string) (sysInfo entity.SystemInfo, err error)
- func GetTaskEmailMarkdownContent(t model.Task, s model.Spider) string
- func GetTaskErrorLog(id string, n int) (errLogItems []model.ErrorLogItem, err error)
- func GetTaskLog(id string, keyword string, page int, pageSize int) (logItems []model.LogItem, logTotal int, err error)
- func GetTaskMarkdownContent(t model.Task, s model.Spider) string
- func GetWorkerPrefix(id int) string
- func GitCheckout(s model.Spider, hash string) (err error)
- func InitCleanService() error
- func InitDeleteLogPeriodically() error
- func InitDemoSpiders()
- func InitDepsFetcher() error
- func InitLogIndexes() error
- func InitLogService() error
- func InitNodeService() error
- func InitProjectCleanUserIds()
- func InitScheduleCleanUserIds()
- func InitScheduler() error
- func InitSpiderCleanUserIds()
- func InitSpiderService() error
- func InitTaskCleanUserIds()
- func InitTaskExecutor() error
- func InitUserService() error
- func IsInstalledDep(installedDepList []entity.Dependency, dep entity.Dependency) bool
- func IsMasterNode(id string) bool
- func IsUniqueConfigSpiderFields(fields []entity.Field) bool
- func MakeToken(user *model.User) (tokenStr string, err error)
- func ParserCron(spec string) error
- func ProcessSpiderFilesFromConfigData(spider model.Spider, configData entity.ConfigSpiderData) error
- func PublishAllSpiders()
- func PublishSpider(spider model.Spider)
- func ReadFileByStep(filePath string, handle func([]byte, *mgo.GridFile), fileCreate *mgo.GridFile) error
- func RemoveSpider(id string) error
- func ResetSpiderGit(s model.Spider) (err error)
- func RestartTask(id string, uid bson.ObjectId) (err error)
- func RetryUploadToGridFs(fileName string, filePath string) (fid bson.ObjectId, err error)
- func SaveScrapyItems(s model.Spider, itemsData []entity.ScrapyItem) (err error)
- func SaveScrapySettings(s model.Spider, settingsData []entity.ScrapySettingParam) (err error)
- func SaveSpiderGitSyncError(s model.Spider, errMsg string)
- func SaveTaskResultCount(id string) func()
- func ScanErrorLogs(t model.Task) func()
- func SecretFunc() jwt.Keyfunc
- func SendHeartBeat()
- func SendNotifications(u model.User, t model.Task, s model.Spider)
- func SendTaskDingTalk(u model.User, t model.Task, s model.Spider)
- func SendTaskEmail(u model.User, t model.Task, s model.Spider)
- func SendTaskWechat(u model.User, t model.Task, s model.Spider)
- func SendWebHookRequest(u model.User, t model.Task, s model.Spider)
- func SetEnv(cmd *exec.Cmd, envs []model.Env, task model.Task, spider model.Spider) *exec.Cmd
- func SetLogConfig(wg *sync.WaitGroup, cmd *exec.Cmd, t model.Task, u model.User) error
- func SpiderFileCheck(t model.Task, spider model.Spider) error
- func StartTaskProcess(cmd *exec.Cmd, t model.Task) error
- func SyncSpiderGit(s model.Spider) (err error)
- func UpdateGitCron()
- func UpdateNodeData()
- func UpdateNodeInfo(data *Data) (err error)
- func UpdateNodeStatus()
- func UpdateNodeStatusPeriodically()
- func UpdateOfflineNodeTaskToAbnormalPeriodically()
- func UpdatePythonDepList()
- func UpdateSchedules()
- func UpdateSpiderDedup(spider model.Spider) error
- func UploadSpiderToGridFsFromMaster(spider model.Spider) error
- func UploadToGridFs(fileName string, filePath string) (fid bson.ObjectId, err error)
- func ValidateSpiderfile(configData entity.ConfigSpiderData) error
- func WaitTaskProcess(cmd *exec.Cmd, t model.Task, s model.Spider) error
- func WriteToGridFS(content []byte, f *mgo.GridFile)
- type Data
- type Executor
- type GitBranch
- type GitCommit
- type GitCronScheduler
- type GitTag
- type PythonDepJsonData
- type PythonDepJsonDataInfo
- type PythonDepNameDict
- type PythonDepNameDictSlice
- type Scheduler
- type SpiderFileData
- type SpiderUploadMessage
- type TaskMessage
Constants ¶
This section is empty.
Variables ¶
View Source
var LockList sync.Map
任务执行锁 Added by cloud: 2019/09/04,solve data race
View Source
var SystemInfoChanMap = utils.NewChanMap()
系统信息 chan 映射
View Source
var TaskLogChanMap = utils.NewChanMap()
任务日志频道映射
Functions ¶
func AddScheduleTask ¶
func CancelSpider ¶
func CancelTask ¶
func CreateNewUser ¶
func CreateResultsIndexes ¶
func CreateResultsIndexes(col string)
func CreateScrapyProject ¶
func CreateScrapySpider ¶
func ExecuteShellCmd ¶
func ExecuteShellCmd(cmdStr string, cwd string, t model.Task, s model.Spider, u model.User) (err error)
执行shell命令
func FetchPythonDepInfo ¶
func FetchPythonDepInfo(depName string) (entity.Dependency, error)
func FinishOrCancelTask ¶
func GenerateConfigSpiderFiles ¶
func GenerateConfigSpiderFiles(spider model.Spider, configData entity.ConfigSpiderData) error
func GenerateSpiderfileFromConfigData ¶
func GenerateSpiderfileFromConfigData(spider model.Spider, configData entity.ConfigSpiderData) error
func GetAdminUser ¶
func GetGitRemoteBranchesPlain ¶
func GetGitRemoteBranchesPlain(gitUrl string, username string, password string) (branches []string, err error)
获得Git分支
func GetLangInstallStatus ¶
获取语言安装状态
func GetLatestRelease ¶
func GetNodejsDepList ¶
func GetNodejsDepList(nodeId string, searchDepName string) (depList []entity.Dependency, err error)
获取Nodejs本地依赖列表
func GetPythonDepList ¶
func GetPythonDepList(nodeId string, searchDepName string) ([]entity.Dependency, error)
获取Python本地依赖列表
func GetPythonDepListFromRedis ¶
从Redis获取Python依赖列表
func GetPythonDepListWithInfo ¶
func GetPythonDepListWithInfo(depList []entity.Dependency) ([]entity.Dependency, error)
获取Python依赖的源数据信息
func GetScrapySettings ¶
func GetScrapySpiderFilepath ¶
func GetSystemInfo ¶
func GetSystemInfo(nodeId string) (sysInfo entity.SystemInfo, err error)
获取系统信息
func GetTaskErrorLog ¶
func GetTaskErrorLog(id string, n int) (errLogItems []model.ErrorLogItem, err error)
func GetTaskLog ¶
func GetWorkerPrefix ¶
func InitCleanService ¶
func InitCleanService() error
func InitDemoSpiders ¶
func InitDemoSpiders()
func InitLogIndexes ¶
func InitLogIndexes() error
func InitLogService ¶
func InitLogService() error
func InitProjectCleanUserIds ¶
func InitProjectCleanUserIds()
func InitScheduleCleanUserIds ¶
func InitScheduleCleanUserIds()
func InitScheduler ¶
func InitScheduler() error
func InitSpiderCleanUserIds ¶
func InitSpiderCleanUserIds()
func InitTaskCleanUserIds ¶
func InitTaskCleanUserIds()
func InitTaskExecutor ¶
func InitTaskExecutor() error
func InitUserService ¶
func InitUserService() error
func IsInstalledDep ¶
func IsInstalledDep(installedDepList []entity.Dependency, dep entity.Dependency) bool
是否已安装该依赖
func IsMasterNode ¶
所有调用IsMasterNode的方法,都永远会在master节点执行,所以GetCurrentNode方法返回永远是master节点 该ID的节点是否为主节点
func ProcessSpiderFilesFromConfigData ¶
func ProcessSpiderFilesFromConfigData(spider model.Spider, configData entity.ConfigSpiderData) error
func ReadFileByStep ¶
func ReadFileByStep(filePath string, handle func([]byte, *mgo.GridFile), fileCreate *mgo.GridFile) error
分片读取大文件
func RemoveSpider ¶
func RetryUploadToGridFs ¶
带重试功能的上传至 GridFS
func SaveScrapyItems ¶
func SaveScrapyItems(s model.Spider, itemsData []entity.ScrapyItem) (err error)
func SaveScrapySettings ¶
func SaveScrapySettings(s model.Spider, settingsData []entity.ScrapySettingParam) (err error)
func SaveSpiderGitSyncError ¶
保存爬虫Git同步错误
func SecretFunc ¶
func SetLogConfig ¶
func UpdateOfflineNodeTaskToAbnormalPeriodically ¶
func UpdateOfflineNodeTaskToAbnormalPeriodically()
每60秒更新异常节点信息
func UpdateSchedules ¶
func UpdateSchedules()
func UpdateSpiderDedup ¶
func UploadSpiderToGridFsFromMaster ¶
从主节点上传爬虫到GridFS
func UploadToGridFs ¶
上传zip文件到GridFS
func ValidateSpiderfile ¶
func ValidateSpiderfile(configData entity.ConfigSpiderData) error
验证Spiderfile
Types ¶
type Data ¶
type Data struct {
Key string `json:"key"`
Mac string `json:"mac"`
Ip string `json:"ip"`
Hostname string `json:"hostname"`
Name string `json:"name"`
NameType string `json:"name_type"`
Master bool `json:"master"`
UpdateTs time.Time `json:"update_ts"`
UpdateTsUnix int64 `json:"update_ts_unix"`
}
func GetRedisNode ¶
type GitBranch ¶
type GitCommit ¶
type GitCommit struct {
Hash string `json:"hash"`
TreeHash string `json:"tree_hash"`
Author string `json:"author"`
Email string `json:"email"`
Message string `json:"message"`
IsHead bool `json:"is_head"`
Ts time.Time `json:"ts"`
Branches []GitBranch `json:"branches"`
RemoteBranches []GitBranch `json:"remote_branches"`
Tags []GitTag `json:"tags"`
}
type GitCronScheduler ¶
type GitCronScheduler struct {
// contains filtered or unexported fields
}
var GitCron *GitCronScheduler
func (*GitCronScheduler) RemoveAll ¶
func (g *GitCronScheduler) RemoveAll()
func (*GitCronScheduler) Start ¶
func (g *GitCronScheduler) Start() error
func (*GitCronScheduler) Update ¶
func (g *GitCronScheduler) Update() error
type GitTag ¶
type PythonDepJsonData ¶
type PythonDepJsonData struct {
Info PythonDepJsonDataInfo `json:"info"`
}
type PythonDepJsonDataInfo ¶
type PythonDepNameDict ¶
type PythonDepNameDictSlice ¶
type PythonDepNameDictSlice []PythonDepNameDict
func (PythonDepNameDictSlice) Len ¶
func (s PythonDepNameDictSlice) Len() int
func (PythonDepNameDictSlice) Less ¶
func (s PythonDepNameDictSlice) Less(i, j int) bool
func (PythonDepNameDictSlice) Swap ¶
func (s PythonDepNameDictSlice) Swap(i, j int)
type Scheduler ¶
type Scheduler struct {
// contains filtered or unexported fields
}
var Sched *Scheduler
type SpiderFileData ¶
type SpiderUploadMessage ¶
type TaskMessage ¶
任务消息
Source Files
¶
Click to show internal directories.
Click to hide internal directories.