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
Show 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
metrics_port
=
28010
private_key
=
"E671C143A110C239B563F702E9F4017CA6B2B2912F675EED9AA4FED684EB30CC"
standard_task_file
=
"standardtask.json"
worker_multiple
=
2
[redis]
addr
=
"127.0.0.1:6379"
...
...
config/Config.go
View file @
1e18df0c
...
...
@@ -46,6 +46,7 @@ type Config struct {
//Endpoint string `json:"endpoint" toml:"endpoint"`
MetricPort
int
`json:"metrics_port" toml:"metrics_port"`
EnablePay
bool
`json:"enable_pay" toml:"enable_pay"`
WorkerMultiple
int
`json:"worker_multiple" toml:"worker_multiple"`
Redis
RedisConfig
`json:"redis" toml:"redis"`
DbConfig
MysqlConfig
`json:"mysql" toml:"mysql"`
Tickers
TickerConfig
`json:"ticker" toml:"ticker"`
...
...
@@ -90,3 +91,11 @@ func (conf *Config) ApiEndpoint() string {
func
(
conf
*
Config
)
StandardTaskFilePath
()
string
{
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,11 +64,13 @@ func (wm *WorkerManager) AddWorkerFirst(worker *Worker) error {
// add device to redis
priority
:=
0
_
=
device
// todo: set priority with device info.
for
m
:=
0
;
m
<
config
.
GetConfig
()
.
GetWorkerMultiple
();
m
++
{
// add worker to redis queue
if
err
:=
wm
.
rdb
.
RPush
(
context
.
Background
(),
config
.
WORKER_QUEUE_PREFIX
+
strconv
.
Itoa
(
priority
),
workerId
(
worker
))
.
Err
();
err
!=
nil
{
continue
}
}
}
return
nil
}
...
...
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