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
8d31f7b8
Commit
8d31f7b8
authored
Feb 03, 2024
by
vicotor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update server
parent
f6e6c29b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
3 deletions
+20
-3
workerManager.go
server/workerManager.go
+2
-2
workerstatu.go
server/workerstatu.go
+18
-1
No files found.
server/workerManager.go
View file @
8d31f7b8
...
@@ -384,7 +384,7 @@ func (wm *WorkerManager) manageWorker(worker *Worker) error {
...
@@ -384,7 +384,7 @@ func (wm *WorkerManager) manageWorker(worker *Worker) error {
}
}
go
wm
.
doCallback
(
task
.
TaskCallback
,
taskResponse
)
go
wm
.
doCallback
(
task
.
TaskCallback
,
taskResponse
)
_
=
wm
.
AddWorker
(
worker
)
_
=
wm
.
AddWorker
Single
(
worker
)
wm
.
Payment
(
task
)
wm
.
Payment
(
task
)
return
true
return
true
...
@@ -475,7 +475,7 @@ func (wm *WorkerManager) handleWorkerMsg(worker *Worker) {
...
@@ -475,7 +475,7 @@ func (wm *WorkerManager) handleWorkerMsg(worker *Worker) {
}
}
worker
.
deviceInfoHash
=
infoHash
[
:
]
worker
.
deviceInfoHash
=
infoHash
[
:
]
}
}
wm
.
AddWorker
(
worker
)
wm
.
AddWorker
First
(
worker
)
wm
.
SetWorkerAddr
(
worker
,
worker
.
addr
)
wm
.
SetWorkerAddr
(
worker
,
worker
.
addr
)
}
}
}
}
...
...
server/workerstatu.go
View file @
8d31f7b8
...
@@ -3,6 +3,7 @@ package server
...
@@ -3,6 +3,7 @@ package server
import
(
import
(
"context"
"context"
"github.com/odysseus/nodemanager/config"
"github.com/odysseus/nodemanager/config"
log
"github.com/sirupsen/logrus"
"strconv"
"strconv"
)
)
...
@@ -12,7 +13,8 @@ func (wm *WorkerManager) UpdateWorkerDeviceInfo(worker *Worker, deviceInfos stri
...
@@ -12,7 +13,8 @@ func (wm *WorkerManager) UpdateWorkerDeviceInfo(worker *Worker, deviceInfos stri
}
}
func
(
wm
*
WorkerManager
)
AddWorker
(
worker
*
Worker
)
error
{
func
(
wm
*
WorkerManager
)
AddWorkerFirst
(
worker
*
Worker
)
error
{
log
.
WithField
(
"worker"
,
worker
.
addr
)
.
Info
(
"add worker first time."
)
for
_
,
device
:=
range
worker
.
deviceInfo
{
for
_
,
device
:=
range
worker
.
deviceInfo
{
// add device to redis
// add device to redis
priority
:=
0
priority
:=
0
...
@@ -28,6 +30,21 @@ func (wm *WorkerManager) AddWorker(worker *Worker) error {
...
@@ -28,6 +30,21 @@ func (wm *WorkerManager) AddWorker(worker *Worker) error {
return
nil
return
nil
}
}
func
(
wm
*
WorkerManager
)
AddWorkerSingle
(
worker
*
Worker
)
error
{
log
.
WithField
(
"worker"
,
worker
.
addr
)
.
Info
(
"add worker on back."
)
{
// add device to redis
priority
:=
0
if
err
:=
wm
.
rdb
.
LPush
(
context
.
Background
(),
config
.
WORKER_QUEUE_PREFIX
+
strconv
.
Itoa
(
priority
),
worker
.
addr
)
.
Err
();
err
!=
nil
{
}
}
// add worker to redis queue
if
err
:=
wm
.
rdb
.
SAdd
(
context
.
Background
(),
config
.
WORKER_STATUS_PREFIX
+
worker
.
addr
,
config
.
GetConfig
()
.
LocalEndpoint
())
.
Err
();
err
!=
nil
{
return
err
}
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
()
.
LocalEndpoint
())
wm
.
rdb
.
SAdd
(
context
.
Background
(),
config
.
WORKER_STATUS_PREFIX
+
worker
.
addr
,
config
.
GetConfig
()
.
LocalEndpoint
())
}
}
...
...
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