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
eca18ce2
authored
Apr 04, 2025
by
CaIon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: Improve setup check logic and logging for system initialization
parent
ad7a64e5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
3 deletions
+10
-3
model/main.go
+10
-3
No files found.
model/main.go
View file @
eca18ce2
...
@@ -57,22 +57,29 @@ func createRootAccountIfNeed() error {
...
@@ -57,22 +57,29 @@ func createRootAccountIfNeed() error {
}
}
func
checkSetup
()
{
func
checkSetup
()
{
if
GetSetup
()
==
nil
{
setup
:=
GetSetup
()
if
setup
==
nil
{
// No setup record exists, check if we have a root user
if
RootUserExists
()
{
if
RootUserExists
()
{
common
.
SysLog
(
"system is not initialized, but root user exists"
)
common
.
SysLog
(
"system is not initialized, but root user exists"
)
// Create setup record
// Create setup record
s
etup
:=
Setup
{
newS
etup
:=
Setup
{
Version
:
common
.
Version
,
Version
:
common
.
Version
,
InitializedAt
:
time
.
Now
()
.
Unix
(),
InitializedAt
:
time
.
Now
()
.
Unix
(),
}
}
err
:=
DB
.
Create
(
&
s
etup
)
.
Error
err
:=
DB
.
Create
(
&
newS
etup
)
.
Error
if
err
!=
nil
{
if
err
!=
nil
{
common
.
SysLog
(
"failed to create setup record: "
+
err
.
Error
())
common
.
SysLog
(
"failed to create setup record: "
+
err
.
Error
())
}
}
constant
.
Setup
=
true
constant
.
Setup
=
true
}
else
{
}
else
{
common
.
SysLog
(
"system is not initialized and no root user exists"
)
constant
.
Setup
=
false
constant
.
Setup
=
false
}
}
}
else
{
// Setup record exists, system is initialized
common
.
SysLog
(
"system is already initialized at: "
+
time
.
Unix
(
setup
.
InitializedAt
,
0
)
.
String
())
constant
.
Setup
=
true
}
}
}
}
...
...
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