Crontab service of golang
# Linux
ETCD_VER=v3.3.20
# choose either URL
GOOGLE_URL=https://storage.googleapis.com/etcd
GITHUB_URL=https://github.com/etcd-io/etcd/releases/download
DOWNLOAD_URL=${GOOGLE_URL}
rm -f /tmp/etcd-${ETCD_VER}-linux-amd64.tar.gz
rm -rf /tmp/etcd-download-test && mkdir -p /tmp/etcd-download-test
curl -L ${DOWNLOAD_URL}/${ETCD_VER}/etcd-${ETCD_VER}-linux-amd64.tar.gz -o /tmp/etcd-${ETCD_VER}-linux-amd64.tar.gz
tar xzvf /tmp/etcd-${ETCD_VER}-linux-amd64.tar.gz -C /tmp/etcd-download-test --strip-components=1
rm -f /tmp/etcd-${ETCD_VER}-linux-amd64.tar.gz
/tmp/etcd-download-test/etcd --version
ETCDCTL_API=3 /tmp/etcd-download-test/etcdctl version
cd /tmp/etcd-download-test
nohup ./etcd --listen-client-urls 'http://0.0.0.0:2379' --advertise-client-urls 'http://0.0.0.0:2379' &
#
less nohup.out
cd /tmp/etcd-download-test
# get
ETCDCTL_API=3 ./etcdctl get /cron/lock/ --prefix
# watch
ETCDCTL_API=3 ./etcdctl get /cron/lock/ --prefix
# delete
ETCDCTL_API=3 ./etcdctl del /cron/lock/ --prefix
- 从etcd从取出task存入内存中
- 实现调度模块,基于cronexpr调度多个task
- 实现执行模块,并发的执行多个task
- 通过分布式锁来限制task在集群中的并发
- 将执行日志保存至mongodb