release revsuit vBeta0.1.0 (#15)

Co-authored-by: E99p1ant <[email protected]>
This commit is contained in:
Li4n0
2021-05-16 12:11:35 +08:00
committed by GitHub
co-authored by E99p1ant
parent b39ee101f9
commit 5b63e90390
98 changed files with 2357 additions and 623 deletions
+32 -22
View File
@@ -14,7 +14,10 @@ import (
log "unknwon.dev/clog/v2"
)
const VERSION = "Beta0.1"
type Revsuit struct {
config *Config
logLevel log.Level
http *http.Server
@@ -25,6 +28,11 @@ type Revsuit struct {
}
func initDatabase(dsn string) {
_ = log.NewConsole(100,
log.ConsoleConfig{
Level: log.LevelInfo,
})
err := database.InitDB("sqlite", dsn)
if err != nil {
log.Fatal(err.Error())
@@ -104,6 +112,10 @@ func initLog(level string) (logLevel log.Level) {
gin.SetMode(gin.ReleaseMode)
database.DB.Logger.LogMode(logger.Error)
logLevel = log.LevelFatal
default:
gin.SetMode(gin.DebugMode)
database.DB.Logger.LogMode(logger.Info)
logLevel = log.LevelInfo
}
_ = log.NewConsole(100,
log.ConsoleConfig{
@@ -138,29 +150,27 @@ func initNotice(nc noticeConfig) {
func New(c *Config) *Revsuit {
logLevel := initLog(c.LogLevel)
initDatabase(c.Database)
logLevel := initLog(c.LogLevel)
initNotice(c.Notice)
s := &Revsuit{
config: c,
logLevel: logLevel,
http: http.GetServer(),
}
if c.DNS.Enable {
s.dns = dns.GetServer()
}
if c.MySQL.Enable {
s.mysql = mysql.GetServer()
s.mysql.Config = c.MySQL
}
if c.RMI.Enable {
s.rmi = rmi.GetServer()
s.rmi.Config = c.RMI
}
if c.FTP.Enable {
s.ftp = ftp.GetServer()
s.ftp.Config = c.FTP
}
s.dns = dns.GetServer()
s.dns.Config = c.DNS
s.mysql = mysql.GetServer()
s.mysql.Config = c.MySQL
s.rmi = rmi.GetServer()
s.rmi.Config = c.RMI
s.ftp = ftp.GetServer()
s.ftp.Config = c.FTP
if c.Addr != "" {
s.http.SetAddr(c.Addr)
@@ -178,16 +188,16 @@ func (revsuit *Revsuit) Run() {
defer log.Stop()
revsuit.registerRouter()
if revsuit.dns != nil {
if revsuit.dns != nil && revsuit.dns.Enable {
go revsuit.dns.Run()
}
if revsuit.mysql != nil {
go revsuit.mysql.Run()
}
if revsuit.rmi != nil {
if revsuit.rmi != nil && revsuit.rmi.Enable {
go revsuit.rmi.Run()
}
if revsuit.ftp != nil {
if revsuit.mysql != nil && revsuit.mysql.Enable {
go revsuit.mysql.Run()
}
if revsuit.ftp != nil && revsuit.ftp.Enable {
go revsuit.ftp.Run()
}