Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nodemanager
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Odysseus
nodemanager
Commits
98feb121
Commit
98feb121
authored
Jan 16, 2024
by
vicotor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add dbinit
parent
23ed2b25
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
2 deletions
+8
-2
rootcmd.go
cmd/manager/rootcmd.go
+2
-0
config.toml
config.toml
+1
-1
db.go
model/db.go
+5
-1
No files found.
cmd/manager/rootcmd.go
View file @
98feb121
...
...
@@ -4,6 +4,7 @@ import (
rotatelogs
"github.com/lestrrat-go/file-rotatelogs"
"github.com/odysseus/nodemanager/config"
"github.com/odysseus/nodemanager/metrics"
"github.com/odysseus/nodemanager/model"
"github.com/odysseus/nodemanager/server"
"github.com/rifflock/lfshook"
log
"github.com/sirupsen/logrus"
...
...
@@ -69,6 +70,7 @@ func initConfig() {
}
func
runNode
()
{
model
.
DbInit
()
n
:=
server
.
NewNode
()
if
err
:=
n
.
Start
();
err
!=
nil
{
log
.
WithError
(
err
)
.
Error
(
"run node failed"
)
...
...
config.toml
View file @
98feb121
...
...
@@ -8,7 +8,7 @@ password="123456"
db
=
0
[mysql]
host
=
"1
27.0.0.
1"
host
=
"1
92.168.1.21
1"
port
=
3306
user
=
"root"
password
=
"12345678"
...
...
model/db.go
View file @
98feb121
...
...
@@ -4,6 +4,7 @@ import (
"fmt"
"github.com/astaxie/beego/orm"
"github.com/odysseus/nodemanager/config"
log
"github.com/sirupsen/logrus"
)
func
DbInit
()
{
...
...
@@ -11,6 +12,9 @@ func DbInit() {
dbconf
:=
config
.
GetConfig
()
.
DbConfig
datasource
:=
fmt
.
Sprintf
(
"%s:%s@tcp(%s:%s)/%s?charset=utf8"
,
dbconf
.
User
,
dbconf
.
Passwd
,
dbconf
.
Host
,
dbconf
.
Port
,
dbconf
.
DbName
)
orm
.
RegisterDriver
(
"mysql"
,
orm
.
DRMySQL
)
orm
.
RegisterDataBase
(
"default"
,
"mysql"
,
datasource
)
err
:=
orm
.
RegisterDataBase
(
"default"
,
"mysql"
,
datasource
)
if
err
!=
nil
{
log
.
WithError
(
err
)
.
Fatal
(
"failed to connect to database"
)
}
orm
.
RegisterModel
(
new
(
User
))
}
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