memos/bin/server/main.go

57 lines
1.6 KiB
Go
Raw Normal View History

2022-02-03 15:32:03 +08:00
package main
2022-08-24 21:53:12 +08:00
import (
"os"
_ "github.com/mattn/go-sqlite3"
"github.com/pkg/errors"
2022-08-24 21:53:12 +08:00
2022-09-05 21:14:17 +08:00
"context"
"fmt"
"github.com/usememos/memos/server"
"github.com/usememos/memos/server/profile"
2022-08-24 21:53:12 +08:00
)
2022-02-03 15:32:03 +08:00
2022-09-05 21:14:17 +08:00
const (
greetingBanner = `
`
)
2023-01-03 20:05:37 +08:00
func run() error {
2022-09-05 21:14:17 +08:00
ctx := context.Background()
2023-01-03 20:05:37 +08:00
profile, err := profile.GetProfile()
if err != nil {
return err
}
println("---")
println("profile")
println("mode:", profile.Mode)
println("port:", profile.Port)
println("dsn:", profile.DSN)
println("version:", profile.Version)
println("---")
2022-09-05 21:14:17 +08:00
serverInstance, err := server.NewServer(ctx, profile)
if err != nil {
return errors.Wrap(err, "failed to start server")
2022-09-05 21:14:17 +08:00
}
println(greetingBanner)
fmt.Printf("Version %s has started at :%d\n", profile.Version, profile.Port)
return serverInstance.Start(ctx)
2022-09-05 21:14:17 +08:00
}
2022-02-03 15:32:03 +08:00
func main() {
2023-01-03 20:05:37 +08:00
if err := run(); err != nil {
fmt.Printf("error: %+v\n", err)
2022-08-24 21:53:12 +08:00
os.Exit(1)
}
2022-02-03 15:32:03 +08:00
}