Unified Task Scheduling platform Scheduler for Golang

Source: Internet
Author: User
Tags gocode
This is a creation in Article, where the information may have evolved or changed.

In enterprise project development, the corresponding job will be executed regularly, and for some simple jobs, the scheduler can be used to dispatch tasks directly. As companies become more and more business, more and more tasks are being performed. Scheduling task execution directly with the Task Scheduler can become bloated, and dynamic configuration is not possible for the task. such as: Want to stop the execution of a task at a certain moment, delete this task and then modify the update task execution time, etc., such as when a task is configured on more than one machine how to do not be available, transfer and so on.
To solve such problems, we need to separate the scheduling and execution of tasks. There is a unified task scheduling center-a task-specific scheduling distribution task, the individual tasks of the task execution assigned to each project. So as to achieve the unified configuration and management of the task.

#基础环境

#GO环境

cd/usr/local/src/

Mkdir-p $HOME/GOCODE/SRC

#

TAR-ZXF go1.8.3.linux-amd64.tar.gz #Https://www.golangtc.com/download

#

Echo-e ' export gopath= $HOME/gocode\nexport goroot=/usr/local/go\nexport gobin= $GOROOT/bin\nexport gopkg= $GOROOT/pkg /tool/linux_amd64\nexport goarch=amd64\nexport goos=linux\nexport path=.: $PATH: $GOBIN: $GOPKG ' >>/etc/profile

#

Source/etc/profile

#

Go version

Go version go1.8.3 linux/amd64

#DB环境

Yum Install epel-release ntpdate chrony-y

RPM-IVH http://repo.mysql.com/mysql-community-release-el6.rpm

Yum Install Mysql-server mysql-client-y

Service mysqld Start

Mysqladmin-uroot password ' 123456 '

>create database Scheduler;grant all privileges on * * to@192.168.28.131 identified by ' 12345678 '; flush privileges;

#scheduler安装

CD $GOPATH/SRC

git clone Https://github.com/shotdog/scheduler

Go get Github.com/astaxie/beego

Go get Github.com/shotdog/quartz

Go get Github.com/go-sql-driver/mysql

#init DB Scheduler.sql

MYSQL-UROOT-P Scheduler < Scheduler.sql

#modify conf/app.conf-->database Config

Vim scheduler/conf/app.conf

Db_path =/usr/bin/mysql

Db_host = 192.168.28.131

Db_port = 3306

Db_user = root

Db_pass = 12345678

Db_name = Scheduler

Db_type = MySQL

#modify main.go-->database Config

Func init () {

Orm. Registerdriver ("MySQL", Orm.) Drmysql)

Orm. RegisterDatabase ("default", "MySQL", "root:12345678@/scheduler?charset=utf8&loc=local")

Orm. Registermodel (&entity. Jobinfo{},&entity. Jobinfohistory{},&entity. jobsnapshot{})

}

#scheduler运行

CD $GOPATH

CD src

CD Scheduler

Go Build Main.go

./main

#client测试

CD $HOME/src && git clone https://github.com/shotdog/scheduler-client.git

CD scheduler-client

Go Build Main.go

./main

Link

Https://github.com/shotdog/scheduler

Https://github.com/shotdog/kitty

http://www.quartz-scheduler.org/

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.