mirror of https://github.com/jlelse/GoBlog
Only wait with queue processing if queue is empty
This commit is contained in:
parent
0dd256579a
commit
b5faa6bbb2
|
@ -80,9 +80,7 @@ func initActivityPub() error {
|
|||
return err
|
||||
}
|
||||
// Init send queue
|
||||
if err = initAPSendQueue(); err != nil {
|
||||
return err
|
||||
}
|
||||
initAPSendQueue()
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -19,15 +19,9 @@ type apRequest struct {
|
|||
Try int
|
||||
}
|
||||
|
||||
func initAPSendQueue() (err error) {
|
||||
startAPSendQueue()
|
||||
return nil
|
||||
}
|
||||
|
||||
func startAPSendQueue() {
|
||||
func initAPSendQueue() {
|
||||
go func() {
|
||||
for {
|
||||
time.Sleep(3 * time.Second)
|
||||
qi, err := peekQueue("ap")
|
||||
if err != nil {
|
||||
log.Println(err.Error())
|
||||
|
@ -56,6 +50,9 @@ func startAPSendQueue() {
|
|||
if err != nil {
|
||||
log.Println(err.Error())
|
||||
}
|
||||
} else {
|
||||
// No item in the queue, wait a moment
|
||||
time.Sleep(15 * time.Second)
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
|
5
main.go
5
main.go
|
@ -130,10 +130,7 @@ func main() {
|
|||
logErrAndQuit("Failed to init ActivityPub:", err.Error())
|
||||
return
|
||||
}
|
||||
if err = initWebmention(); err != nil {
|
||||
logErrAndQuit("Failed to init webmention support:", err.Error())
|
||||
return
|
||||
}
|
||||
initWebmention()
|
||||
initTelegram()
|
||||
initBlogStats()
|
||||
initSessions()
|
||||
|
|
|
@ -30,7 +30,7 @@ type mention struct {
|
|||
Status webmentionStatus
|
||||
}
|
||||
|
||||
func initWebmention() error {
|
||||
func initWebmention() {
|
||||
// Add hooks
|
||||
hookFunc := func(p *post) {
|
||||
if p.Status == statusPublished {
|
||||
|
@ -41,7 +41,7 @@ func initWebmention() error {
|
|||
postHooks[postUpdateHook] = append(postHooks[postUpdateHook], hookFunc)
|
||||
postHooks[postDeleteHook] = append(postHooks[postDeleteHook], hookFunc)
|
||||
// Start verifier
|
||||
return initWebmentionQueue()
|
||||
initWebmentionQueue()
|
||||
}
|
||||
|
||||
func handleWebmention(w http.ResponseWriter, r *http.Request) {
|
||||
|
|
|
@ -20,15 +20,9 @@ import (
|
|||
"willnorris.com/go/microformats"
|
||||
)
|
||||
|
||||
func initWebmentionQueue() (err error) {
|
||||
startWebmentionQueue()
|
||||
return nil
|
||||
}
|
||||
|
||||
func startWebmentionQueue() {
|
||||
func initWebmentionQueue() {
|
||||
go func() {
|
||||
for {
|
||||
time.Sleep(10 * time.Second)
|
||||
qi, err := peekQueue("wm")
|
||||
if err != nil {
|
||||
log.Println(err.Error())
|
||||
|
@ -49,6 +43,9 @@ func startWebmentionQueue() {
|
|||
if err != nil {
|
||||
log.Println(err.Error())
|
||||
}
|
||||
} else {
|
||||
// No item in the queue, wait a moment
|
||||
time.Sleep(15 * time.Second)
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
|
Loading…
Reference in New Issue