-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.go
49 lines (40 loc) · 827 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
46
47
48
49
package main
import (
"flag"
"fmt"
"github.com/BurntSushi/toml"
"github.com/supme/smtpRelay/model"
"github.com/supme/smtpRelay/sender"
"github.com/supme/smtpRelay/server"
"os"
)
const version = "v0.3.0"
var configFile string
func init() {
ver := flag.Bool("v", false, "print current version")
flag.StringVar(&configFile, "c", "./config.ini", "Config file")
flag.Parse()
if *ver {
fmt.Println(version)
os.Exit(0)
}
}
func main() {
if _, err := toml.DecodeFile(configFile, &model.Config); err != nil {
panic(err)
}
err := model.OpenQueueDb()
if err != nil {
panic(err)
}
defer model.QueueDb.Close()
err = model.OpenStatusDb()
if err != nil {
panic(err)
}
defer model.StatusDb.Close()
fmt.Println("Start SMTP sender")
sender.Run()
fmt.Println("Starting SMTP server...")
server.Run()
}