-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.go
More file actions
43 lines (39 loc) · 902 Bytes
/
main.go
File metadata and controls
43 lines (39 loc) · 902 Bytes
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
package main
import (
"context"
"os"
"os/signal"
"syscall"
"goto-bangumi/internal/core"
"path/filepath"
)
func main() {
// logDir 和 dbDir 为同一目录
logDir := "./data"
posterDir := filepath.Join(logDir, "posters")
if _, err := os.Stat(logDir); os.IsNotExist(err) {
if err := os.MkdirAll(logDir, 0o755); err != nil {
return
}
}
// 创建海报目录(如果不存在)
if err := os.MkdirAll(posterDir, 0o755); err != nil {
return
}
ctx, cancel := context.WithCancel(context.Background())
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt,syscall.SIGTERM)
go func() {
<-c
cancel()
}()
program := core.InitProgram(ctx)
program.Start(ctx)
<-ctx.Done()
// 启动 API 服务器(阻塞)
// server := api.NewServer()
// // 或者指定端口: server := api.NewServerWithPort(8080)
// if err := server.Run(); err != nil {
// panic(err)
// }
}