Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
b0b0ed20
authored
Jun 22, 2023
by
JustSong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: print more logs
parent
64d026fc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
2 deletions
+6
-2
common/redis.go
+2
-1
model/main.go
+4
-1
No files found.
common/redis.go
View file @
b0b0ed20
...
@@ -17,9 +17,10 @@ func InitRedisClient() (err error) {
...
@@ -17,9 +17,10 @@ func InitRedisClient() (err error) {
SysLog
(
"REDIS_CONN_STRING not set, Redis is not enabled"
)
SysLog
(
"REDIS_CONN_STRING not set, Redis is not enabled"
)
return
nil
return
nil
}
}
SysLog
(
"Redis is enabled"
)
opt
,
err
:=
redis
.
ParseURL
(
os
.
Getenv
(
"REDIS_CONN_STRING"
))
opt
,
err
:=
redis
.
ParseURL
(
os
.
Getenv
(
"REDIS_CONN_STRING"
))
if
err
!=
nil
{
if
err
!=
nil
{
panic
(
err
)
FatalLog
(
err
)
}
}
RDB
=
redis
.
NewClient
(
opt
)
RDB
=
redis
.
NewClient
(
opt
)
...
...
model/main.go
View file @
b0b0ed20
...
@@ -42,17 +42,19 @@ func InitDB() (err error) {
...
@@ -42,17 +42,19 @@ func InitDB() (err error) {
var
db
*
gorm
.
DB
var
db
*
gorm
.
DB
if
os
.
Getenv
(
"SQL_DSN"
)
!=
""
{
if
os
.
Getenv
(
"SQL_DSN"
)
!=
""
{
// Use MySQL
// Use MySQL
common
.
SysLog
(
"using MySQL as database"
)
db
,
err
=
gorm
.
Open
(
mysql
.
Open
(
os
.
Getenv
(
"SQL_DSN"
)),
&
gorm
.
Config
{
db
,
err
=
gorm
.
Open
(
mysql
.
Open
(
os
.
Getenv
(
"SQL_DSN"
)),
&
gorm
.
Config
{
PrepareStmt
:
true
,
// precompile SQL
PrepareStmt
:
true
,
// precompile SQL
})
})
}
else
{
}
else
{
// Use SQLite
// Use SQLite
common
.
SysLog
(
"SQL_DSN not set, using SQLite as database"
)
common
.
UsingSQLite
=
true
common
.
UsingSQLite
=
true
db
,
err
=
gorm
.
Open
(
sqlite
.
Open
(
common
.
SQLitePath
),
&
gorm
.
Config
{
db
,
err
=
gorm
.
Open
(
sqlite
.
Open
(
common
.
SQLitePath
),
&
gorm
.
Config
{
PrepareStmt
:
true
,
// precompile SQL
PrepareStmt
:
true
,
// precompile SQL
})
})
common
.
SysLog
(
"SQL_DSN not set, using SQLite as database"
)
}
}
common
.
SysLog
(
"Database connected"
)
if
err
==
nil
{
if
err
==
nil
{
DB
=
db
DB
=
db
if
!
common
.
IsMasterNode
{
if
!
common
.
IsMasterNode
{
...
@@ -86,6 +88,7 @@ func InitDB() (err error) {
...
@@ -86,6 +88,7 @@ func InitDB() (err error) {
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
common
.
SysLog
(
"Database migrated"
)
err
=
createRootAccountIfNeed
()
err
=
createRootAccountIfNeed
()
return
err
return
err
}
else
{
}
else
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment