mirror of
https://github.com/crawlab-team/crawlab.git
synced 2026-01-21 17:21:09 +01:00
加入配置只在工作节点上调度
This commit is contained in:
@@ -243,16 +243,16 @@ func main() {
|
||||
{
|
||||
authGroup.GET("/variables", routes.GetVariableList) // 列表
|
||||
authGroup.PUT("/variable", routes.PutVariable) // 新增
|
||||
authGroup.POST("/variable/:id", routes.PostVariable) //修改
|
||||
authGroup.DELETE("/variable/:id", routes.DeleteVariable) //删除
|
||||
authGroup.POST("/variable/:id", routes.PostVariable) // 修改
|
||||
authGroup.DELETE("/variable/:id", routes.DeleteVariable) // 删除
|
||||
}
|
||||
// 项目
|
||||
{
|
||||
authGroup.GET("/projects", routes.GetProjectList) // 列表
|
||||
authGroup.GET("/projects/tags", routes.GetProjectTags) // 项目标签
|
||||
authGroup.PUT("/projects", routes.PutProject) //修改
|
||||
authGroup.PUT("/projects", routes.PutProject) // 修改
|
||||
authGroup.POST("/projects/:id", routes.PostProject) // 新增
|
||||
authGroup.DELETE("/projects/:id", routes.DeleteProject) //删除
|
||||
authGroup.DELETE("/projects/:id", routes.DeleteProject) // 删除
|
||||
}
|
||||
// 统计数据
|
||||
authGroup.GET("/stats/home", routes.GetHomeStats) // 首页统计数据
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
type SettingBody struct {
|
||||
AllowRegister string `json:"allow_register"`
|
||||
EnableTutorial string `json:"enable_tutorial"`
|
||||
RunOnMaster string `json:"run_on_master"`
|
||||
}
|
||||
|
||||
func GetVersion(c *gin.Context) {
|
||||
@@ -25,6 +26,7 @@ func GetSetting(c *gin.Context) {
|
||||
body := SettingBody{
|
||||
AllowRegister: viper.GetString("setting.allowRegister"),
|
||||
EnableTutorial: viper.GetString("setting.enableTutorial"),
|
||||
RunOnMaster: viper.GetString("setting.runOnMaster"),
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, Response{
|
||||
|
||||
@@ -853,10 +853,18 @@ func SendNotifications(u model.User, t model.Task, s model.Spider) {
|
||||
}
|
||||
|
||||
func InitTaskExecutor() error {
|
||||
// 构造任务执行器
|
||||
c := cron.New(cron.WithSeconds())
|
||||
Exec = &Executor{
|
||||
Cron: c,
|
||||
}
|
||||
|
||||
// 如果不允许主节点运行任务,则跳过
|
||||
if model.IsMaster() && viper.GetString("setting.runOnMaster") == "N" {
|
||||
return nil
|
||||
}
|
||||
|
||||
// 运行定时任务
|
||||
if err := Exec.Start(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
v-for="op in nodeList"
|
||||
:key="op._id"
|
||||
:value="op._id"
|
||||
:disabled="op.status !== 'online'"
|
||||
:disabled="isNodeDisabled(op)"
|
||||
:label="op.name"
|
||||
/>
|
||||
</el-select>
|
||||
@@ -139,6 +139,9 @@ export default {
|
||||
...mapState('spider', [
|
||||
'spiderForm'
|
||||
]),
|
||||
...mapState('setting', [
|
||||
'setting'
|
||||
]),
|
||||
isConfirmDisabled () {
|
||||
if (this.isLoading) return true
|
||||
if (!this.isAllowDisclaimer) return true
|
||||
@@ -291,6 +294,11 @@ export default {
|
||||
onParametersConfirm (value) {
|
||||
this.form.param = value
|
||||
this.isParametersVisible = false
|
||||
},
|
||||
isNodeDisabled (node) {
|
||||
if (node.status !== 'online') return true
|
||||
if (node.is_master && this.setting.run_on_master === 'N') return true
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user