forked from Virtomize/mail2most
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
55 lines (41 loc) · 963 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
50
51
52
53
54
55
package main
import (
"flag"
"log"
"context"
m2m "github.com/justledbetter/mail2most/lib"
"github.com/aws/aws-lambda-go/lambda"
)
var LAMBDA_BUILD string = ""
func LambdaHandler(ctx context.Context, config m2m.Config) (string, error) {
// Lambda does not support writing files, so we need to force some reasonable defaults.
//
config.NoStateFile = true
config.General.File = ""
config.General.NoLoop = true
config.Logging.Logtype = "json"
config.Logging.Output = "stdout"
m, err := m2m.NewFromJson(config)
if err != nil {
return "done", err
}
err = m.Run()
return "done", err
}
func main() {
if LAMBDA_BUILD != "" {
log.Println("Executing Lambda runtime")
lambda.Start(LambdaHandler)
} else {
confFile := flag.String("c", "conf/mail2most.conf", "path to config file")
flag.Parse()
m, err := m2m.New(*confFile)
if err != nil {
log.Fatal(err)
}
err = m.Run()
if err != nil {
log.Fatal(err)
}
}
}