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
53542c44
Commit
53542c44
authored
Feb 02, 2024
by
vicotor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update config
parent
dd1bff0b
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
7 deletions
+13
-7
config.toml
config.toml
+2
-1
Config.go
config/Config.go
+7
-2
registry.go
nmregistry/registry.go
+1
-1
workerstatu.go
server/workerstatu.go
+3
-3
No files found.
config.toml
View file @
53542c44
host
=
"127.0.0.1"
remote_host
=
""
local_host
=
"127.0.0.1"
port
=
10001
port
=
10001
metrics_port
=
28010
metrics_port
=
28010
private_key
=
"E671C143A110C239B563F702E9F4017CA6B2B2912F675EED9AA4FED684EB30CC"
private_key
=
"E671C143A110C239B563F702E9F4017CA6B2B2912F675EED9AA4FED684EB30CC"
...
...
config/Config.go
View file @
53542c44
...
@@ -36,7 +36,8 @@ type TickerConfig struct {
...
@@ -36,7 +36,8 @@ type TickerConfig struct {
type
Config
struct
{
type
Config
struct
{
PrivateKey
string
`json:"private_key" toml:"private_key"`
PrivateKey
string
`json:"private_key" toml:"private_key"`
Host
string
`json:"host" toml:"host"`
RemoteHost
string
`json:"remote_host" toml:"remote_host"`
LocalHost
string
`json:"local_host" toml:"local_host"`
Port
int
`json:"port" toml:"port"`
Port
int
`json:"port" toml:"port"`
//Endpoint string `json:"endpoint" toml:"endpoint"`
//Endpoint string `json:"endpoint" toml:"endpoint"`
MetricPort
int
`json:"metrics_port" toml:"metrics_port"`
MetricPort
int
`json:"metrics_port" toml:"metrics_port"`
...
@@ -68,7 +69,11 @@ func GetConfig() *Config {
...
@@ -68,7 +69,11 @@ func GetConfig() *Config {
return
_cfg
return
_cfg
}
}
func
(
conf
*
Config
)
PublicEndpoint
()
string
{
func
(
conf
*
Config
)
PublicEndpoint
()
string
{
return
fmt
.
Sprintf
(
"%s:%d"
,
conf
.
Host
,
conf
.
Port
)
return
fmt
.
Sprintf
(
"%s:%d"
,
conf
.
RemoteHost
,
conf
.
Port
)
}
func
(
conf
*
Config
)
LocalEndpoint
()
string
{
return
fmt
.
Sprintf
(
"%s:%d"
,
conf
.
LocalHost
,
conf
.
Port
)
}
}
func
(
conf
*
Config
)
ApiEndpoint
()
string
{
func
(
conf
*
Config
)
ApiEndpoint
()
string
{
...
...
nmregistry/registry.go
View file @
53542c44
...
@@ -88,7 +88,7 @@ func (s *RegistryService) registry(rdb *redis.Client) error {
...
@@ -88,7 +88,7 @@ func (s *RegistryService) registry(rdb *redis.Client) error {
addr
:=
utils
.
PrivatekeyToHex
(
priv
)
addr
:=
utils
.
PrivatekeyToHex
(
priv
)
pubHex
:=
utils
.
PubkeyToHex
(
&
priv
.
PublicKey
)
pubHex
:=
utils
.
PubkeyToHex
(
&
priv
.
PublicKey
)
endpoint
:=
fmt
.
Sprintf
(
"%s:%d"
,
s
.
conf
.
Host
,
s
.
conf
.
Port
)
endpoint
:=
s
.
conf
.
PublicEndpoint
(
)
err
=
rdb
.
HSet
(
context
.
Background
(),
config
.
NODE_MANAGER_SET
+
addr
,
RegistryInfo
{
err
=
rdb
.
HSet
(
context
.
Background
(),
config
.
NODE_MANAGER_SET
+
addr
,
RegistryInfo
{
Pubkey
:
pubHex
,
Pubkey
:
pubHex
,
...
...
server/workerstatu.go
View file @
53542c44
...
@@ -22,16 +22,16 @@ func (wm *WorkerManager) AddWorker(worker *Worker) error {
...
@@ -22,16 +22,16 @@ func (wm *WorkerManager) AddWorker(worker *Worker) error {
}
}
}
}
// add worker to redis queue
// add worker to redis queue
if
err
:=
wm
.
rdb
.
SAdd
(
context
.
Background
(),
config
.
WORKER_STATUS_PREFIX
+
worker
.
addr
,
config
.
GetConfig
()
.
Public
Endpoint
())
.
Err
();
err
!=
nil
{
if
err
:=
wm
.
rdb
.
SAdd
(
context
.
Background
(),
config
.
WORKER_STATUS_PREFIX
+
worker
.
addr
,
config
.
GetConfig
()
.
Local
Endpoint
())
.
Err
();
err
!=
nil
{
return
err
return
err
}
}
return
nil
return
nil
}
}
func
(
wm
*
WorkerManager
)
ActiveWorker
(
worker
*
Worker
)
{
func
(
wm
*
WorkerManager
)
ActiveWorker
(
worker
*
Worker
)
{
wm
.
rdb
.
SAdd
(
context
.
Background
(),
config
.
WORKER_STATUS_PREFIX
+
worker
.
addr
,
config
.
GetConfig
()
.
Public
Endpoint
())
wm
.
rdb
.
SAdd
(
context
.
Background
(),
config
.
WORKER_STATUS_PREFIX
+
worker
.
addr
,
config
.
GetConfig
()
.
Local
Endpoint
())
}
}
func
(
wm
*
WorkerManager
)
InActiveWorker
(
worker
*
Worker
)
{
func
(
wm
*
WorkerManager
)
InActiveWorker
(
worker
*
Worker
)
{
wm
.
rdb
.
SRem
(
context
.
Background
(),
config
.
WORKER_STATUS_PREFIX
+
worker
.
addr
,
config
.
GetConfig
()
.
Public
Endpoint
())
wm
.
rdb
.
SRem
(
context
.
Background
(),
config
.
WORKER_STATUS_PREFIX
+
worker
.
addr
,
config
.
GetConfig
()
.
Local
Endpoint
())
}
}
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