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
1e18df0c
Commit
1e18df0c
authored
Mar 20, 2024
by
vicotor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add worker multiple config.
parent
4719dd73
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
9 deletions
+21
-9
config.toml
config.toml
+1
-0
Config.go
config/Config.go
+15
-6
workerstatu.go
server/workerstatu.go
+5
-3
No files found.
config.toml
View file @
1e18df0c
...
@@ -4,6 +4,7 @@ port=10001
...
@@ -4,6 +4,7 @@ port=10001
metrics_port
=
28010
metrics_port
=
28010
private_key
=
"E671C143A110C239B563F702E9F4017CA6B2B2912F675EED9AA4FED684EB30CC"
private_key
=
"E671C143A110C239B563F702E9F4017CA6B2B2912F675EED9AA4FED684EB30CC"
standard_task_file
=
"standardtask.json"
standard_task_file
=
"standardtask.json"
worker_multiple
=
2
[redis]
[redis]
addr
=
"127.0.0.1:6379"
addr
=
"127.0.0.1:6379"
...
...
config/Config.go
View file @
1e18df0c
...
@@ -44,12 +44,13 @@ type Config struct {
...
@@ -44,12 +44,13 @@ type Config struct {
Port
int
`json:"port" toml:"port"`
Port
int
`json:"port" toml:"port"`
StandardTaskFile
string
`json:"standard_task_file" toml:"standard_task_file"`
StandardTaskFile
string
`json:"standard_task_file" toml:"standard_task_file"`
//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"`
EnablePay
bool
`json:"enable_pay" toml:"enable_pay"`
EnablePay
bool
`json:"enable_pay" toml:"enable_pay"`
Redis
RedisConfig
`json:"redis" toml:"redis"`
WorkerMultiple
int
`json:"worker_multiple" toml:"worker_multiple"`
DbConfig
MysqlConfig
`json:"mysql" toml:"mysql"`
Redis
RedisConfig
`json:"redis" toml:"redis"`
Tickers
TickerConfig
`json:"ticker" toml:"ticker"`
DbConfig
MysqlConfig
`json:"mysql" toml:"mysql"`
Kafka
KafkaConfig
`json:"kafka" toml:"kafka"`
Tickers
TickerConfig
`json:"ticker" toml:"ticker"`
Kafka
KafkaConfig
`json:"kafka" toml:"kafka"`
}
}
var
_cfg
*
Config
=
nil
var
_cfg
*
Config
=
nil
...
@@ -90,3 +91,11 @@ func (conf *Config) ApiEndpoint() string {
...
@@ -90,3 +91,11 @@ func (conf *Config) ApiEndpoint() string {
func
(
conf
*
Config
)
StandardTaskFilePath
()
string
{
func
(
conf
*
Config
)
StandardTaskFilePath
()
string
{
return
conf
.
StandardTaskFile
return
conf
.
StandardTaskFile
}
}
func
(
conf
*
Config
)
GetWorkerMultiple
()
int
{
if
conf
.
WorkerMultiple
>
0
{
return
conf
.
WorkerMultiple
}
else
{
return
1
}
}
server/workerstatu.go
View file @
1e18df0c
...
@@ -64,9 +64,11 @@ func (wm *WorkerManager) AddWorkerFirst(worker *Worker) error {
...
@@ -64,9 +64,11 @@ func (wm *WorkerManager) AddWorkerFirst(worker *Worker) error {
// add device to redis
// add device to redis
priority
:=
0
priority
:=
0
_
=
device
// todo: set priority with device info.
_
=
device
// todo: set priority with device info.
// add worker to redis queue
for
m
:=
0
;
m
<
config
.
GetConfig
()
.
GetWorkerMultiple
();
m
++
{
if
err
:=
wm
.
rdb
.
RPush
(
context
.
Background
(),
config
.
WORKER_QUEUE_PREFIX
+
strconv
.
Itoa
(
priority
),
workerId
(
worker
))
.
Err
();
err
!=
nil
{
// add worker to redis queue
continue
if
err
:=
wm
.
rdb
.
RPush
(
context
.
Background
(),
config
.
WORKER_QUEUE_PREFIX
+
strconv
.
Itoa
(
priority
),
workerId
(
worker
))
.
Err
();
err
!=
nil
{
continue
}
}
}
}
}
...
...
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