- Unify login page styling with share page - Add AGENTS.md with build commands and code style guidelines - Add dev.sh and make.sh for development and production builds - Implement single binary build with embedded frontend using embed.FS - Change auth configuration from CLI flag to env variables (USHARE_USERNAME, USHARE_PASSWORD) - Set default credentials: admin / ushare@123 - Fix static file serving for SPA routes
42 lines
1002 B
Go
42 lines
1002 B
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"flag"
|
|
"github.com/loveuer/nf/nft/log"
|
|
"github.com/loveuer/ushare/internal/api"
|
|
"github.com/loveuer/ushare/internal/controller"
|
|
"github.com/loveuer/ushare/internal/opt"
|
|
"github.com/loveuer/ushare/internal/pkg/tool"
|
|
"os/signal"
|
|
"syscall"
|
|
)
|
|
|
|
func init() {
|
|
flag.BoolVar(&opt.Cfg.Debug, "debug", false, "debug mode")
|
|
flag.StringVar(&opt.Cfg.Address, "address", "0.0.0.0:9119", "")
|
|
flag.StringVar(&opt.Cfg.DataPath, "data", "/data", "")
|
|
flag.IntVar(&opt.Cfg.CleanInterval, "clean", 24, "清理文件的周期, 单位: 小时, 0 则表示不自动清理")
|
|
flag.Parse()
|
|
|
|
opt.LoadFromEnv()
|
|
|
|
if opt.Cfg.Debug {
|
|
log.SetLogLevel(log.LogLevelDebug)
|
|
tool.TablePrinter(opt.Cfg)
|
|
}
|
|
}
|
|
|
|
func main() {
|
|
ctx, cancel := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
|
|
defer cancel()
|
|
|
|
opt.Init(ctx)
|
|
controller.UserManager.Start(ctx)
|
|
controller.MetaManager.Start(ctx)
|
|
controller.RoomController.Start(ctx)
|
|
api.Start(ctx)
|
|
|
|
<-ctx.Done()
|
|
}
|