/
main.go
59 lines (42 loc) · 885 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package main
import (
"fmt"
"log"
"github.com/robfig/cron"
"techtoolkit.ickey.cn/crawlerNode/links"
)
//AJob struct
type AJob struct {
l *links.Links
}
//Run interface
func (m *AJob) Run() {
fmt.Println("I am runnning task.")
u := "http://www.anglia-live.com"
seeds, err := m.l.GetSeedURLS(u)
if err != nil {
fmt.Println("get init seed error")
log.Fatal(err)
}
m.l.LinksList(seeds)
}
func taskWithParams(a int, b string) {
fmt.Println(a, b)
}
func main() {
m := &AJob{}
m.l = links.NewLinks()
defer m.l.Close()
///////////////
//var job AJob
done := make(chan struct{})
c := cron.New()
defer c.Stop()
//seconds - minutes - hours - day of mounth - month - day of week (0-6 , SUN to SAT)
//will run a lot of times running task times.
//c.AddJob("* 44 20 * * 2", m)
// run once
c.AddJob("0 01 09 * * 6", m)
c.Start()
done <- struct{}{}
}