removed cron job
This commit is contained in:
parent
826c906777
commit
62bfead182
@ -9,7 +9,6 @@ import (
|
|||||||
"git.paulbsd.com/paulbsd/ipbl/src/models"
|
"git.paulbsd.com/paulbsd/ipbl/src/models"
|
||||||
"git.paulbsd.com/paulbsd/ipbl/src/routers"
|
"git.paulbsd.com/paulbsd/ipbl/src/routers"
|
||||||
_ "github.com/lib/pq"
|
_ "github.com/lib/pq"
|
||||||
"github.com/robfig/cron"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
//go:generate ../../scripts/version.sh
|
//go:generate ../../scripts/version.sh
|
||||||
@ -17,7 +16,6 @@ import (
|
|||||||
func main() {
|
func main() {
|
||||||
var ctx context.Context
|
var ctx context.Context
|
||||||
var cfg config.Config
|
var cfg config.Config
|
||||||
var lock bool
|
|
||||||
cfg.GetConfig()
|
cfg.GetConfig()
|
||||||
cfg.Options.Version = version
|
cfg.Options.Version = version
|
||||||
|
|
||||||
@ -29,14 +27,14 @@ func main() {
|
|||||||
defer cfg.Db.Close()
|
defer cfg.Db.Close()
|
||||||
|
|
||||||
// Handles IP with no reverse DNS
|
// Handles IP with no reverse DNS
|
||||||
go models.ScanIP(&cfg, &lock)
|
go models.ScanIP(&cfg)
|
||||||
|
|
||||||
// Add cron task to handle them
|
// Add cron task to handle them
|
||||||
cr := cron.New()
|
//cr := cron.New()
|
||||||
cr.AddFunc("0 * * * * *", func() {
|
//cr.AddFunc("0 * * * * *", func() {
|
||||||
models.ScanIP(&cfg, &lock)
|
// models.ScanIP(&cfg)
|
||||||
})
|
//})
|
||||||
cr.Start()
|
//cr.Start()
|
||||||
|
|
||||||
// Run the ipbl web service
|
// Run the ipbl web service
|
||||||
err = routers.RunServer(&ctx, &cfg)
|
err = routers.RunServer(&ctx, &cfg)
|
||||||
|
@ -64,9 +64,7 @@ func InsertIPBulk(cfg *config.Config, ips *[]IP) (numinserts int64, numfail int6
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func ScanIP(cfg *config.Config, lock *bool) (err error) {
|
func ScanIP(cfg *config.Config) (err error) {
|
||||||
if !*lock {
|
|
||||||
*lock = true
|
|
||||||
for {
|
for {
|
||||||
var orphans = []IP{}
|
var orphans = []IP{}
|
||||||
cfg.Db.Where("rdns IS NULL").Asc("ip").Find(&orphans)
|
cfg.Db.Where("rdns IS NULL").Asc("ip").Find(&orphans)
|
||||||
@ -87,13 +85,10 @@ func ScanIP(cfg *config.Config, lock *bool) (err error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
break
|
time.Sleep(60 * time.Second)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*lock = false
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// APIFormat returns a JSON formatted object of IP
|
// APIFormat returns a JSON formatted object of IP
|
||||||
func (admin *IP) APIFormat() *api.IP {
|
func (admin *IP) APIFormat() *api.IP {
|
||||||
|
Loading…
Reference in New Issue
Block a user