mirror of
https://github.com/Li4n0/revsuit.git
synced 2026-09-26 00:21:54 +08:00
release revsuit vBeta0.1.0 (#15)
Co-authored-by: E99p1ant <[email protected]>
This commit is contained in:
+32
-22
@@ -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()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user