Documentation ¶
Index ¶
- Constants
- Variables
- func InitTables() error
- func InitTask()
- type Access
- type Admin
- type AdminRole
- type DingtalkNotice
- type EmailNotice
- type Menu
- type MenuTree
- type Notice
- type NoticeSetting
- type Project
- func (p *Project) Del(id int) (bool, string)
- func (p *Project) Find() []Project
- func (p *Project) Get(id int) bool
- func (p *Project) GetPageProjects(serverId int, page int, pageSize int) ([]Project, int)
- func (p *Project) InsertOne(relation string, serverIds []int, file *multipart.FileHeader) (bool, string, []string)
- func (p *Project) Update(id int, data core.A) error
- func (p *Project) UpdateServers(serverIds []int, file *multipart.FileHeader) (bool, string)
- func (p *Project) UpdateVersion(useHistoryVersion string, version string, file *multipart.FileHeader) (bool, string)
- type ProjectHistory
- type ProjectServer
- type SchedulesTask
- func (s *SchedulesTask) Del(id int) bool
- func (s *SchedulesTask) FindPages(projectId int, version string, serverId int, status string, page int, ...) ([]core.B, int)
- func (s *SchedulesTask) HaveEnabled(projectId int) bool
- func (s *SchedulesTask) HaveEnabledByServer(serverId int) bool
- func (s *SchedulesTask) Inert(projectId int, projectName string, version string, cron string, ...) bool
- func (s *SchedulesTask) InitSchedulesToCron() bool
- func (s *SchedulesTask) RunSchedules()
- func (s *SchedulesTask) UpdateStatus() bool
- type Scrapyd
- func (s *Scrapyd) AddVersion(project *Project, file *multipart.FileHeader) bool
- func (s *Scrapyd) Cancel(projectName string, jobId string) error
- func (s *Scrapyd) DaemonStatus() error
- func (s *Scrapyd) DelProject(projectName string) bool
- func (s *Scrapyd) ListJobs(projectName string) (error, map[string][]interface{})
- func (s *Scrapyd) ListSpiders(project *Project) (error, []string)
- func (s *Scrapyd) Schedule(projectName string, version string, spiderName string) (error, string)
- type Server
- func (s *Server) Del(id int) (bool, string)
- func (s *Server) DetectionStatus()
- func (s *Server) Find() []Server
- func (s *Server) FindByIds(ids []int) []Server
- func (s *Server) FindByProjectId(projectId int) []Server
- func (s *Server) FindByProjectIdNotProject(projectId int) []Server
- func (s *Server) Get(id int) bool
- func (s *Server) InsertOne() (bool, string)
- func (s *Server) PageList(projectId int, page int, pageSize int) ([]Server, int)
- func (s *Server) ServerMonitor()
- func (s *Server) Update(id int, data core.A) error
- type ServerMonitor
- type Spider
- func (s *Spider) CountByProjectId(projectId int) int
- func (s *Spider) FindByProjectIdAndVersion(projectId int, version string) []core.B
- func (s *Spider) FindBySpiderIds(spiderIds []string) []Spider
- func (s *Spider) FindPageSpiders(projectId int, version string, page int, pageSize int, order string) ([]core.B, int)
- func (s *Spider) UpdateProjectSpiders(p *Project, spiderNames []string, session *xorm.Session) bool
- type Task
- func (t *Task) Cancel(id int) bool
- func (t *Task) CancelAll(projectId int, version string, serverId int, status string) (bool, []string)
- func (t *Task) CancelMulti(ids []string) (bool, []string)
- func (t *Task) Del(id int) bool
- func (t *Task) DelAll(projectId int, version string, serverId int, status string) bool
- func (t *Task) DelMulti(ids []string) bool
- func (t *Task) DetectionStatus()
- func (t *Task) FindTaskPages(projectId int, version string, serverId int, status string, page int, ...) ([]core.B, int)
- func (t *Task) HaveRunning(projectId int) bool
- func (t *Task) HaveRunningByServer(serverId int) bool
- func (t *Task) Inert(projectId int, projectName string, version string, spiderList []string, ...) (bool, []string)
- func (t *Task) InertOne()
- func (t *Task) RunTask(taskId int)
- type WorkWeixinNotice
Constants ¶
View Source
const ( AdminStatusNormal = "enabled" AdminStatusDisabled = "disabled" )
View Source
const ( MenuStatusEnable = 1 //菜单显示状态 MenuStatusDisable = 2 //菜单禁用状态 )
Variables ¶
View Source
var ( NoticeSettingStatusEnabled = "enabled" //启用 NoticeSettingStatusDisabled = "disabled" //禁用 NoticeOptionScrapyd = "scrapyd_service" //scrapyd服务监控状态 NoticeOptionTaskFinished = "task_finished" //是否监听任务完成 NoticeOptionTaskError = "task_error" //是否监听任务异常 NoticeSettingWildcards = map[string][]string{ NoticeOptionScrapyd: {"{host}", "{error_time}", "{error_message}"}, NoticeOptionTaskFinished: {"{job_id}", "{task_id}", "{host}", "{project}", "{version}", "{spider}", "{start_time}", "{end_time}", "{duration_time}"}, NoticeOptionTaskError: {"{job_id}", "{task_id}", "{host}", "{project}", "{version}", "{spider}", "{start_time}", "{error_time}", "{duration_time}", "{error_message}"}, } )
View Source
var ( SchedulesTaskStatusEnabled = "enabled" SchedulesTaskStatusDisabled = "disabled" )
View Source
var ( ServerStatusNormal uint8 = 1 //服务器状态正常 ServerStatusFault uint8 = 2 //服务器状态故障 ServerAuthClose uint8 = 1 //服务器验证关闭 ServerAuthOpen uint8 = 2 //服务器验证开启 ServerMonitorDisabled = "disabled" //关闭服务器监控 ServerMonitorEnabled = "enabled" //开启服务器监控 ServerAgentStatusNormal uint8 = 1 //代理状态正常 ServerAgentStatusFault uint8 = 2 //代理状态故障 )
View Source
var ( SpiderStatusNormal uint8 = 1 //爬虫状态正常 ServerStatusDiscard uint8 = 2 //爬虫状态废弃 )
View Source
var ( TaskTypeOnce uint8 = 1 //一次性任务 TaskTypeTiming uint8 = 2 //定时任务 TaskStatusError = "error" TaskStatusPending = "pending" TaskStatusRunning = "running" TaskStatusCancelled = "cancelled" TaskStatusFinished = "finished" )
Status 运行状态 error | pending | running | cancelled | finished
Functions ¶
func InitTables ¶
func InitTables() error
Types ¶
type Access ¶
type Admin ¶
type Admin struct { core.BaseModel `xorm:"-"` Id int `json:"id" xorm:"pk autoincr"` Username string `json:"username" form:"username" binding:"required" xorm:"username"` Password string `json:"-" form:"password" binding:"required" xorm:"password"` Email string `json:"email" form:"email" xorm:"email"` DisplayName string `json:"display_name" xorm:"display_name"` Status string `json:"status" xorm:"status"` CreateTime core.Timestamp `json:"create_time" xorm:"created"` }
type DingtalkNotice ¶
type EmailNotice ¶
type EmailNotice struct{}
type Menu ¶
type Menu struct { core.BaseModel `xorm:"-"` Id int `xorm:"pk autoincr" json:"id" form:"id"` Name string `json:"name" form:"name"` ParentId int `json:"parent_id" form:"parent_id"` App string `json:"app" form:"app"` Controller string `json:"controller" form:"controller"` Action string `json:"action" form:"action"` Parameter string `json:"parameter" form:"parameter"` Icon string `json:"icon" form:"icon"` Status int `json:"status" form:"status"` ListingOrder int `json:"listing_order" form:"listing_order"` }
type NoticeSetting ¶
type NoticeSetting struct { Base core.BaseModel `json:"-" xorm:"-"` Id int `json:"id" xorm:"pk autoincr"` Name string `json:"name"` Desc string `json:"host" ` Value string `json:"value"` }
func (*NoticeSetting) Find ¶
func (n *NoticeSetting) Find() core.B
type Project ¶
type Project struct { Base core.BaseModel `json:"-" xorm:"-"` Id int `json:"id" xorm:"pk autoincr"` Name string `json:"name" xorm:"unique" binding:"required"` Desc string `json:"desc"` LastVersion string `json:"last_version"` CreateTime core.Timestamp `json:"create_time" xorm:"created"` UpdateTime core.Timestamp `json:"update_time" xorm:"created updated"` }
func (*Project) GetPageProjects ¶
分页获取项目数据
func (*Project) UpdateServers ¶
更新关联服务器
func (*Project) UpdateVersion ¶
func (p *Project) UpdateVersion(useHistoryVersion string, version string, file *multipart.FileHeader) (bool, string)
更新项目文件
type ProjectHistory ¶
type ProjectHistory struct { Base core.BaseModel `json:"-" xorm:"-"` Id int `json:"id" xorm:"pk autoincr"` ProjectId int `json:"project_id" binding:"required"` Version string `json:"version"` CreateTime core.Timestamp `json:"create_time" xorm:"created"` }
func (*ProjectHistory) CountByProjectIdAndVersion ¶
func (p *ProjectHistory) CountByProjectIdAndVersion() int
func (*ProjectHistory) FindByProjectId ¶
func (p *ProjectHistory) FindByProjectId() []core.B
根据项目id获取历史版本记录
type ProjectServer ¶
type ProjectServer struct { Base core.BaseModel `json:"-" xorm:"-"` Id int `json:"id" xorm:"pk autoincr"` ProjectId int `json:"project_id" binding:"required"` ServerId int `json:"server_id" binding:"required"` CreateTime core.Timestamp `json:"create_time" xorm:"created"` }
func (*ProjectServer) DelProjectServers ¶
func (p *ProjectServer) DelProjectServers(projectId int, serverIds []int, session *xorm.Session) error
删除项目下制定的服务器列表
func (*ProjectServer) InsertProjectServers ¶
func (p *ProjectServer) InsertProjectServers(projectId int, serverIds []int, session *xorm.Session) error
批量增加项目下的服务器
type SchedulesTask ¶
type SchedulesTask struct { Base core.BaseModel `json:"-" xorm:"-"` Id int `json:"id" xorm:"pk autoincr"` ProjectId int `json:"project_id"` ProjectName string `json:"project_name"` Version string `json:"version"` ServerId int `json:"server_id"` Host string `json:"host"` SpiderId int `json:"spider_id"` SpiderName string `json:"spider_name"` Cron string `json:"cronn"` Status string `json:"status"` }
func (*SchedulesTask) Del ¶
func (s *SchedulesTask) Del(id int) bool
func (*SchedulesTask) FindPages ¶
func (s *SchedulesTask) FindPages(projectId int, version string, serverId int, status string, page int, pageSize int) ([]core.B, int)
分页获取计划任务列表
func (*SchedulesTask) HaveEnabled ¶
func (s *SchedulesTask) HaveEnabled(projectId int) bool
查询项目下是有正在启用的计划任务
func (*SchedulesTask) HaveEnabledByServer ¶
func (s *SchedulesTask) HaveEnabledByServer(serverId int) bool
func (*SchedulesTask) InitSchedulesToCron ¶
func (s *SchedulesTask) InitSchedulesToCron() bool
初始化计划任务
type Scrapyd ¶
func (*Scrapyd) AddVersion ¶
func (s *Scrapyd) AddVersion(project *Project, file *multipart.FileHeader) bool
添加scrapy项目
func (*Scrapyd) ListSpiders ¶
获取项目中所包含的爬虫列表
type Server ¶
type Server struct { Base core.BaseModel `json:"-" xorm:"-"` Id int `json:"id" xorm:"pk autoincr"` Alias string `json:"alias"` Host string `json:"host" binding:"required"` Username string `json:"-"` Password string `json:"-"` Auth uint8 `json:"auth"` Status uint8 `json:"status"` AgentStatus uint8 `json:"agent_status"` Monitor string `json:"monitor"` MonitorAddress string `json:"monitor_address"` MonitorUsername string `json:"monitor_username"` MonitorPassword string `json:"monitor_password"` CreateTime core.Timestamp `json:"create_time" xorm:"created"` UpdateTime core.Timestamp `json:"update_time" xorm:"created updated"` }
func (*Server) FindByProjectId ¶
根据项目id获取所有服务器
func (*Server) FindByProjectIdNotProject ¶
根据项目id获取所有未拥有此项目的服务器
type ServerMonitor ¶
type ServerMonitor struct { Base core.BaseModel `json:"-" xorm:"-"` Id int `json:"id" xorm:"pk autoincr"` ServerId int `json:"server_id"` MemTotal int64 `json:"mem_total"` MemAvailable int64 `json:"mem_available"` MemUsed int64 `json:"mem_used"` MemUsedPercent string `json:"mem_used_percent"` CpuPercent string `json:"cpu_percent"` CpuCoreCount int `json:"cpu_core_count"` CpuLoad1 string `json:"cpu_load1"` CpuLoad5 string `json:"cpu_load5"` CpuLoad15 string `json:"cpu_load15"` ProcessCount int `json:"process_count"` NetSendSpeed int `json:"net_send_speed"` NetReceiveSpeed int `json:"net_receive_speed"` CreateTime core.Timestamp `json:"create_time"` }
func (*ServerMonitor) FindByLastTime ¶
func (s *ServerMonitor) FindByLastTime(serverId int, lastTime int) []core.A
func (*ServerMonitor) OverviewByIds ¶
func (s *ServerMonitor) OverviewByIds(ids []string) ([]map[string]string, error)
获取服务器性能指标概览
type Spider ¶
type Spider struct { Base core.BaseModel `json:"-" xorm:"-"` Id int `json:"id" xorm:"pk autoincr"` ProjectId int `json:"project_id"` Name string `json:"name"` Version string `json:"version"` Status uint8 `json:"status"` CreateTime core.Timestamp `json:"create_time" xorm:"created"` }
func (*Spider) FindByProjectIdAndVersion ¶
func (*Spider) FindBySpiderIds ¶
type Task ¶
type Task struct { Base core.BaseModel `json:"-" xorm:"-"` Id int `json:"id" xorm:"pk autoincr"` Type uint8 `json:"type"` ProjectId int `json:"project_id"` ProjectName string `json:"project_name"` Version string `json:"version"` ServerId int `json:"server_id"` Host string `json:"host"` SpiderId int `json:"spider_id"` SpiderName string `json:"spider_name"` JobId string `json:"job_id"` StartTime core.Timestamp `json:"start_time"` EndTime core.Timestamp `json:"end_time"` Status string `json:"status"` }
func (*Task) DetectionStatus ¶
func (t *Task) DetectionStatus()
func (*Task) FindTaskPages ¶
func (t *Task) FindTaskPages(projectId int, version string, serverId int, status string, page int, pageSize int) ([]core.B, int)
分页获取任务列表
func (*Task) HaveRunningByServer ¶
type WorkWeixinNotice ¶
Click to show internal directories.
Click to hide internal directories.