mirror of
https://github.com/riwiwa/muzi.git
synced 2026-02-28 11:56:57 -08:00
33 lines
589 B
Go
33 lines
589 B
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"os"
|
|
|
|
"muzi/db"
|
|
"muzi/web"
|
|
|
|
"github.com/jackc/pgx/v5/pgxpool"
|
|
)
|
|
|
|
func check(msg string, err error) {
|
|
if err != nil {
|
|
fmt.Fprintf(os.Stderr, "Error %s: %v\n", msg, err)
|
|
os.Exit(1)
|
|
}
|
|
}
|
|
|
|
func main() {
|
|
check("ensuring muzi DB exists", db.CreateDB())
|
|
|
|
var err error
|
|
db.Pool, err = pgxpool.New(context.Background(), db.GetDbUrl(false))
|
|
check("connecting to muzi database", err)
|
|
defer db.Pool.Close()
|
|
|
|
check("ensuring all tables exist", db.CreateAllTables())
|
|
check("cleaning expired sessions", db.CleanupExpiredSessions())
|
|
web.Start()
|
|
}
|