-
-
Notifications
You must be signed in to change notification settings - Fork 33
/
imail.go
61 lines (47 loc) · 1.25 KB
/
imail.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
package main
import (
"embed"
"os"
"github.com/urfave/cli"
"github.com/midoks/imail/internal/cmd"
"github.com/midoks/imail/internal/conf"
"github.com/midoks/imail/internal/log"
"github.com/midoks/imail/internal/tools"
"github.com/midoks/imail/internal/tools/syscall"
)
const Version = "0.0.19"
const AppName = "imail"
//go:embed templates
var viewsFs embed.FS
//go:embed public/*
var publicFs embed.FS
func init() {
conf.App.Version = Version
conf.App.Name = AppName
conf.App.PublicFs = publicFs
}
func main() {
if tools.IsExist("./logs") {
logFile, err := os.OpenFile("./logs/run_away.log", os.O_CREATE|os.O_APPEND|os.O_RDWR, os.ModePerm)
if err != nil {
panic("Exception capture:Failed to open exception log file")
}
// Redirect the process standard error to the file.
// When the process crashes, the runtime will record the co process call stack information to the file
syscall.Dup2(int(logFile.Fd()), int(os.Stderr.Fd()))
}
app := cli.NewApp()
app.Name = conf.App.Name
app.Version = conf.App.Version
app.Usage = "A simple mail service"
app.Commands = []cli.Command{
cmd.Service,
cmd.Reset,
cmd.Dkim,
cmd.Cert,
cmd.Check,
}
if err := app.Run(os.Args); err != nil {
log.Infof("Failed to start application: %v", err)
}
}