init
This commit is contained in:
parent
4e50fa04b3
commit
6786a50444
|
|
@ -14,7 +14,7 @@ import (
|
|||
// 探针
|
||||
func Probe() {
|
||||
for {
|
||||
time.Sleep(time.Second)
|
||||
time.Sleep(10 * time.Second)
|
||||
db, err := mysql.New()
|
||||
if err != nil {
|
||||
exceptionless.SubmitAppError("Probe", "mysql.New", nil, err)
|
||||
|
|
@ -22,7 +22,7 @@ func Probe() {
|
|||
}
|
||||
|
||||
var domains []*model.Domain
|
||||
if err := db.Where("updated_at<?", time.Now().Add(-10*time.Minute)).Find(&domains).Error; err != nil {
|
||||
if err := db.Where("updated_at<?", time.Now().Add(-3*time.Minute)).Find(&domains).Error; err != nil {
|
||||
if err != gorm.ErrRecordNotFound {
|
||||
exceptionless.SubmitAppError("Probe", "mysql.Find", nil, err)
|
||||
continue
|
||||
|
|
@ -30,13 +30,20 @@ func Probe() {
|
|||
}
|
||||
|
||||
for _, d := range domains {
|
||||
for i := 0; i < 500; i++ {
|
||||
url := fmt.Sprintf(`https://www.%s.%s`, randSeq(), d.Root)
|
||||
if url == "" {
|
||||
continue
|
||||
}
|
||||
siteAccess(&url)
|
||||
}
|
||||
go probeRequest(d)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func probeRequest(domain *model.Domain) {
|
||||
db, _ := mysql.New()
|
||||
for i := 0; i < 100; i++ {
|
||||
url := fmt.Sprintf(`https://www.%s.%s`, randSeq(), domain.Root)
|
||||
siteAccess(&url)
|
||||
domain.UpdatedAt = time.Now()
|
||||
if err := db.Updates(domain).Error; err != nil {
|
||||
exceptionless.SubmitAppError("probeRequest", "mysql.Updates", nil, err)
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue