diff --git a/bootstrap/README.md b/bootstrap/README.md deleted file mode 100644 index 817d3abb46a..00000000000 --- a/bootstrap/README.md +++ /dev/null @@ -1,3 +0,0 @@ -What to do at startup, such as: -- parse config -- init store \ No newline at end of file diff --git a/bootstrap/log.go b/bootstrap/log.go index bfa42f198f9..08a79e8f35d 100644 --- a/bootstrap/log.go +++ b/bootstrap/log.go @@ -4,16 +4,18 @@ import ( "github.com/alist-org/alist/v3/cmd/args" "github.com/alist-org/alist/v3/conf" rotatelogs "github.com/lestrrat-go/file-rotatelogs" - log "github.com/sirupsen/logrus" + "github.com/sirupsen/logrus" + "log" "time" ) func Log() { + log.SetOutput(logrus.StandardLogger().Out) if args.Debug { - log.SetLevel(log.DebugLevel) - log.SetReportCaller(true) + logrus.SetLevel(logrus.DebugLevel) + logrus.SetReportCaller(true) } - log.SetFormatter(&log.TextFormatter{ + logrus.SetFormatter(&logrus.TextFormatter{ ForceColors: true, EnvironmentOverrideColors: true, TimestampFormat: "2006-01-02 15:04:05", @@ -40,9 +42,9 @@ func Log() { ) } if err != nil { - log.Fatalf("failed to create rotate log: %s", err) + logrus.Fatalf("failed to create rotate logrus: %s", err) } - log.SetOutput(writer) + logrus.SetOutput(writer) } - log.Infof("init log...") + logrus.Infof("init logrus...") } diff --git a/cmd/alist.go b/cmd/alist.go index a2e51c3e5db..3ee752fb2e5 100644 --- a/cmd/alist.go +++ b/cmd/alist.go @@ -6,6 +6,8 @@ import ( "github.com/alist-org/alist/v3/bootstrap" "github.com/alist-org/alist/v3/cmd/args" "github.com/alist-org/alist/v3/conf" + "github.com/gin-gonic/gin" + log "github.com/sirupsen/logrus" "os" ) @@ -29,4 +31,21 @@ func Init() { } func main() { Init() + if !args.Debug { + gin.SetMode(gin.ReleaseMode) + } + r := gin.New() + r.Use(gin.LoggerWithWriter(log.StandardLogger().Out), gin.RecoveryWithWriter(log.StandardLogger().Out)) + // TODO: setup router + base := fmt.Sprintf("%s:%d", conf.Conf.Address, conf.Conf.Port) + log.Infof("start server @ %s", base) + var err error + if conf.Conf.Scheme.Https { + err = r.RunTLS(base, conf.Conf.Scheme.CertFile, conf.Conf.Scheme.KeyFile) + } else { + err = r.Run(base) + } + if err != nil { + log.Errorf("failed to start: %s", err.Error()) + } } diff --git a/drivers/local/driver.go b/drivers/local/driver.go new file mode 100644 index 00000000000..469c3dc0d8c --- /dev/null +++ b/drivers/local/driver.go @@ -0,0 +1 @@ +package local diff --git a/internal/model/account.go b/internal/model/account.go index e34db667158..f5c70c91c60 100644 --- a/internal/model/account.go +++ b/internal/model/account.go @@ -4,6 +4,7 @@ type Account struct { ID uint `json:"id" gorm:"primaryKey"` VirtualPath string `json:"virtual_path"` Index int `json:"index"` - Type string `json:"type"` + Driver string `json:"driver"` Status string `json:"status"` + Custom string `json:"custom"` }