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
dd1bff0b
Commit
dd1bff0b
authored
Feb 02, 2024
by
vicotor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update config
parent
50317747
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
21 additions
and
8 deletions
+21
-8
config.toml
config.toml
+2
-1
Config.go
config/Config.go
+12
-2
registry.go
nmregistry/registry.go
+3
-1
node.go
server/node.go
+1
-1
workerstatu.go
server/workerstatu.go
+3
-3
No files found.
config.toml
View file @
dd1bff0b
endpoint
=
"127.0.0.1:10001"
host
=
"127.0.0.1"
port
=
10001
metrics_port
=
28010
private_key
=
"E671C143A110C239B563F702E9F4017CA6B2B2912F675EED9AA4FED684EB30CC"
enable_pay
=
false
...
...
config/Config.go
View file @
dd1bff0b
package
config
import
(
"fmt"
"github.com/BurntSushi/toml"
log
"github.com/sirupsen/logrus"
"io/ioutil"
...
...
@@ -34,8 +35,10 @@ type TickerConfig struct {
}
type
Config
struct
{
PrivateKey
string
`json:"private_key" toml:"private_key"`
Endpoint
string
`json:"endpoint" toml:"endpoint"`
PrivateKey
string
`json:"private_key" toml:"private_key"`
Host
string
`json:"host" toml:"host"`
Port
int
`json:"port" toml:"port"`
//Endpoint string `json:"endpoint" toml:"endpoint"`
MetricPort
int
`json:"metrics_port" toml:"metrics_port"`
EnablePay
bool
`json:"enable_pay" toml:"enable_pay"`
Redis
RedisConfig
`json:"redis" toml:"redis"`
...
...
@@ -64,3 +67,10 @@ func ParseConfig(path string) (*Config, error) {
func
GetConfig
()
*
Config
{
return
_cfg
}
func
(
conf
*
Config
)
PublicEndpoint
()
string
{
return
fmt
.
Sprintf
(
"%s:%d"
,
conf
.
Host
,
conf
.
Port
)
}
func
(
conf
*
Config
)
ApiEndpoint
()
string
{
return
fmt
.
Sprintf
(
"0.0.0.0:%d"
,
conf
.
Port
)
}
nmregistry/registry.go
View file @
dd1bff0b
...
...
@@ -88,10 +88,12 @@ func (s *RegistryService) registry(rdb *redis.Client) error {
addr
:=
utils
.
PrivatekeyToHex
(
priv
)
pubHex
:=
utils
.
PubkeyToHex
(
&
priv
.
PublicKey
)
endpoint
:=
fmt
.
Sprintf
(
"%s:%d"
,
s
.
conf
.
Host
,
s
.
conf
.
Port
)
err
=
rdb
.
HSet
(
context
.
Background
(),
config
.
NODE_MANAGER_SET
+
addr
,
RegistryInfo
{
Pubkey
:
pubHex
,
Timestamp
:
time
.
Now
()
.
Unix
(),
Endpoint
:
s
.
conf
.
E
ndpoint
,
Endpoint
:
e
ndpoint
,
Addr
:
addr
,
})
.
Err
()
return
err
...
...
server/node.go
View file @
dd1bff0b
...
...
@@ -88,7 +88,7 @@ func (n *Node) Start() error {
}
func
(
n
*
Node
)
apiStart
()
error
{
lis
,
err
:=
net
.
Listen
(
"tcp"
,
config
.
GetConfig
()
.
Endpoint
)
lis
,
err
:=
net
.
Listen
(
"tcp"
,
config
.
GetConfig
()
.
ApiEndpoint
()
)
if
err
!=
nil
{
log
.
WithError
(
err
)
.
Error
(
"failed to listen endpoint"
)
return
err
...
...
server/workerstatu.go
View file @
dd1bff0b
...
...
@@ -22,16 +22,16 @@ func (wm *WorkerManager) AddWorker(worker *Worker) error {
}
}
// add worker to redis queue
if
err
:=
wm
.
rdb
.
SAdd
(
context
.
Background
(),
config
.
WORKER_STATUS_PREFIX
+
worker
.
addr
,
config
.
GetConfig
()
.
Endpoint
)
.
Err
();
err
!=
nil
{
if
err
:=
wm
.
rdb
.
SAdd
(
context
.
Background
(),
config
.
WORKER_STATUS_PREFIX
+
worker
.
addr
,
config
.
GetConfig
()
.
PublicEndpoint
()
)
.
Err
();
err
!=
nil
{
return
err
}
return
nil
}
func
(
wm
*
WorkerManager
)
ActiveWorker
(
worker
*
Worker
)
{
wm
.
rdb
.
SAdd
(
context
.
Background
(),
config
.
WORKER_STATUS_PREFIX
+
worker
.
addr
,
config
.
GetConfig
()
.
Endpoint
)
wm
.
rdb
.
SAdd
(
context
.
Background
(),
config
.
WORKER_STATUS_PREFIX
+
worker
.
addr
,
config
.
GetConfig
()
.
PublicEndpoint
()
)
}
func
(
wm
*
WorkerManager
)
InActiveWorker
(
worker
*
Worker
)
{
wm
.
rdb
.
SRem
(
context
.
Background
(),
config
.
WORKER_STATUS_PREFIX
+
worker
.
addr
,
config
.
GetConfig
()
.
Endpoint
)
wm
.
rdb
.
SRem
(
context
.
Background
(),
config
.
WORKER_STATUS_PREFIX
+
worker
.
addr
,
config
.
GetConfig
()
.
PublicEndpoint
()
)
}
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