Commit 77cbacdf by 朱继来

Merge branch 'master' of http://119.23.72.7/sunlong_v5/go-crontab

parents 507349a6 9284e2bf
/worker/main/worker.json
...@@ -42,12 +42,12 @@ func main(){ ...@@ -42,12 +42,12 @@ func main(){
//新增定时任务 //新增定时任务
//putResp, err := kv.Put(context.TODO(),"/cron/jobs/192.168.2.232/job2","{\"name\":\"job2\",\"command\":\"D:/phpstudy/PHPTutorial/php/php-5.6.27-nts/php E:/WWW/a.php\",\"cronExpr\":\"*/7 * * * * * *\"}",clientv3.WithPrevKV()) //putResp, err := kv.Put(context.TODO(),"/cron/jobs/192.168.2.232/job2","{\"name\":\"job2\",\"command\":\"D:/phpstudy/PHPTutorial/php/php-5.6.27-nts/php E:/WWW/a.php\",\"cronExpr\":\"*/7 * * * * * *\"}",clientv3.WithPrevKV())
//putResp, err := kv.Put(context.TODO(),"/cron/jobs/192.168.2.246/job2","{\"name\":\"job2\",\"command\":\" echo hello world\",\"cronExpr\":\"*/5 * * * * * *\"}",clientv3.WithPrevKV()) //putResp, err := kv.Put(context.TODO(),"/cron/jobs/192.168.2.246/job2","{\"name\":\"job2\",\"command\":\" echo hello world\",\"cronExpr\":\"*/5 * * * * * *\"}",clientv3.WithPrevKV())
//putResp, err := kv.Put(context.TODO(),"/cron/jobs/192.168.2.246/job3","{\"name\":\"job3\",\"command\":\" echo hello boy\",\"cronExpr\":\"*/10 * * * * * *\"}",clientv3.WithPrevKV()) putResp, err := kv.Put(context.TODO(),"/cron/jobs/192.168.2.246/job3","{\"name\":\"job3\",\"command\":\" echo hello boy\",\"cronExpr\":\"*/10 * * * * * *\"}",clientv3.WithPrevKV())
//fmt.Println(putResp) //fmt.Println(putResp)
//fmt.Println(err) //fmt.Println(err)
//新增一次性任务 //新增一次性任务
putResp, err := kv.Put(context.TODO(),"/cron/oncejobs/192.168.2.232/job10","{\"name\":\"job10\",\"command\":\" echo hello world \"}",clientv3.WithPrevKV()) //putResp, err := kv.Put(context.TODO(),"/cron/oncejobs/192.168.2.232/job10","{\"name\":\"job10\",\"command\":\" echo hello world \"}",clientv3.WithPrevKV())
//强杀任务 //强杀任务
......
...@@ -13,6 +13,7 @@ type Config struct { ...@@ -13,6 +13,7 @@ type Config struct {
MongodbConnectTimeout int `json:"mongodbConnectTimeout"` MongodbConnectTimeout int `json:"mongodbConnectTimeout"`
JobLogBatchSize int `json:"jobLogBatchSize"` JobLogBatchSize int `json:"jobLogBatchSize"`
JobLogCommitTimeout int `json"jobLogCommitTimeout"` JobLogCommitTimeout int `json"jobLogCommitTimeout"`
ExecCommand string `json"execCommand"`
} }
var ( var (
......
...@@ -55,8 +55,8 @@ func (executor *Executor) ExecuteJob(info *common.JobExecuteInfo) { ...@@ -55,8 +55,8 @@ func (executor *Executor) ExecuteJob(info *common.JobExecuteInfo) {
result.StartTime = time.Now() result.StartTime = time.Now()
// 执行shell命令 // 执行shell命令
//cmd = exec.CommandContext(info.CancelCtx, "/bin/bash", "-c", info.Job.Command) cmd = exec.CommandContext(info.CancelCtx, G_config.ExecCommand, "-c", info.Job.Command)
cmd = exec.CommandContext(info.CancelCtx, "C:\\cygwin64\\bin\\bash.exe", "-c", info.Job.Command) //cmd = exec.CommandContext(info.CancelCtx, "C:\\cygwin64\\bin\\bash.exe", "-c", info.Job.Command)
// 执行并捕获输出 // 执行并捕获输出
output, err = cmd.CombinedOutput() output, err = cmd.CombinedOutput()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment