-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
45 lines (36 loc) · 776 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
package main
import (
"fmt"
"log"
"time"
"glpi_queue_smtp/modules/queues"
"glpi_queue_smtp/modules/smtp"
"github.com/gofor-little/env"
)
func main() {
fmt.Println("Starting")
if err := env.Load(".env"); err != nil {
panic(err)
}
for {
fineshed := make(chan queues.Queue)
getQueue := queues.FindAll(12)
start := time.Now()
if len(getQueue) > 0 {
for _, queue := range getQueue {
queue := queue
go func() {
smtp.Send(queue.To, queue.Name, queue.BodyHTML, queue)
fineshed <- queue
}()
}
for range getQueue {
queue := <-fineshed
log.Println("Enviado: ", queue.ID, " | Name: ", queue.Name)
}
}
elapsed := time.Since(start)
queues.CreateCronTaskLogs(getQueue, elapsed)
time.Sleep(time.Second * 15)
}
}