-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
50 lines (44 loc) · 1.06 KB
/
main.go
File metadata and controls
50 lines (44 loc) · 1.06 KB
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
package main
import (
"fmt"
"log"
"os"
"github.com/Diminho/MK_practice/app"
"github.com/Diminho/MK_practice/config"
"github.com/Diminho/MK_practice/mk_server"
"github.com/Diminho/MK_practice/models"
"github.com/Diminho/MK_practice/simplelog"
_ "github.com/go-sql-driver/mysql"
"golang.org/x/oauth2"
)
func main() {
// os.RemoveAll("/tmp/")
file, err := os.OpenFile("log.txt", os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666)
if err != nil {
log.Fatal("Failed to open log file: ", err)
}
defer func() {
err := file.Close()
if err != nil {
log.Println(err)
}
}()
slog := simplelog.NewLog(file)
db, err := models.Connect(config.Driver, fmt.Sprintf("%s:@%s/%s", config.User, config.Host, config.DbName))
if err != nil {
slog.Fatal(err)
}
mk_server.NewServer(
app.NewApp(
slog,
&oauth2.Config{
ClientID: config.ClientID,
ClientSecret: config.ClientSecret,
RedirectURL: config.RedirectURL,
Scopes: config.Scopes,
Endpoint: config.Endpoint,
},
config.FBState,
config.ServerRootDir,
db.Instance()))
}