-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
96 lines (81 loc) · 2.3 KB
/
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
package main
import (
"flag"
"log"
"os"
"os/signal"
"time"
"github.com/hayrullahcansu/fastmta-core/global"
"github.com/hayrullahcansu/fastmta-core/broker"
OS "github.com/hayrullahcansu/fastmta-core/cross"
"github.com/hayrullahcansu/fastmta-core/logger"
)
var ops int64
const (
Timeout = time.Second * time.Duration(30)
KeepAlive = time.Second * time.Duration(30)
//MtaName = "ZetaMail"
//MaxErrorLimit = 10
)
func main() {
// err := smtp.SendMail("smtp.gmail.com:587",
// smtp.PlainAuth("", from, pass, "smtp.gmail.com"),
// from, []string{to}, []byte(msg))
// host = "gmail-smtp-in.l.google.COM:25"
// dialer := &net.Dialer{
// Timeout: Timeout,
// KeepAlive: KeepAlive,
// LocalAddr: &net.TCPAddr{
// IP: "127.0.0.1",
// },
// }
// conn, err := dialer.Dial("tcp", host)
// if err != nil {
// if opError, ok := err.(*net.OpError); ok {
// if dnsError, ok := opError.Err.(*net.DNSError); ok {
// return false, transaction.HostNotFound, dnsError.Error()
// }
// }
// //TODO: define all error like dnsError
// return false, transaction.ServiceNotAvailable, "service not avaliable"
// }
// load command line arguments
start := time.Now()
//m := &sync.Mutex{}
//runtime.Goexit()
elapsed := time.Since(start)
log.Printf("Binomial took %s", elapsed)
name := flag.String("name", "FastMta", "name to print")
flag.Parse()
log.Printf("Starting service for %s%s", *name, OS.NewLine)
// setup signal catching
sigs := make(chan os.Signal, 1)
// catch all signals since not explicitly listing
signal.Notify(sigs)
//signal.Notify(sigs,syscall.SIGQUIT)
// method invoked upon seeing signal
go func() {
s := <-sigs
logger.Infof("RECEIVED SIGNAL: %s%s", s, OS.NewLine)
AppCleanup()
os.Exit(1)
}()
broker.InitSystem()
broker := broker.New(
global.StaticConfig.ID,
global.StaticConfig.Name,
global.StaticConfig.IsEnabled,
)
// rabbitClient := queue.New()
// rabbitClient.Connect(true)
// _, _ = rabbitClient.Consume(queue.InboundQueueName, "", false, false, true, nil)
// rabbitClient2 := queue.New()
// rabbitClient2.Connect(true)
// _, _ = rabbitClient2.Consume(queue.InboundQueueName, "", false, false, true, nil)
broker.Run()
select {}
}
func AppCleanup() {
time.Sleep(time.Millisecond * time.Duration(1000))
logger.Infof("CLEANUP APP BEFORE EXIT!!!")
}