mirror of
https://github.com/tuna/tunasync.git
synced 2025-04-20 20:22:46 +00:00
feat(worker): implemented extra_status_manager
option to enable a worker reporting status to multi
This commit is contained in:
parent
86153c59e3
commit
a0b8ef08ab
@ -56,7 +56,8 @@ type globalConfig struct {
|
||||
type managerConfig struct {
|
||||
APIBase string `toml:"api_base"`
|
||||
CACert string `toml:"ca_cert"`
|
||||
Token string `toml:"token"`
|
||||
ExtraStatusAPIs []string `toml:"extra_status_managers"`
|
||||
// Token string `toml:"token"`
|
||||
}
|
||||
|
||||
type serverConfig struct {
|
||||
|
@ -405,12 +405,6 @@ func (w *Worker) registorWorker() {
|
||||
}
|
||||
|
||||
func (w *Worker) updateStatus(job *mirrorJob, jobMsg jobMessage) {
|
||||
url := fmt.Sprintf(
|
||||
"%s/workers/%s/jobs/%s",
|
||||
w.cfg.Manager.APIBase,
|
||||
w.Name(),
|
||||
jobMsg.name,
|
||||
)
|
||||
p := job.provider
|
||||
smsg := MirrorStatus{
|
||||
Name: jobMsg.name,
|
||||
@ -422,10 +416,17 @@ func (w *Worker) updateStatus(job *mirrorJob, jobMsg jobMessage) {
|
||||
ErrorMsg: jobMsg.msg,
|
||||
}
|
||||
|
||||
apiBases := []string{w.cfg.Manager.APIBase}
|
||||
apiBases = append(apiBases, w.cfg.Manager.ExtraStatusAPIs...)
|
||||
for _, root := range apiBases {
|
||||
url := fmt.Sprintf(
|
||||
"%s/workers/%s/jobs/%s", root, w.Name(), jobMsg.name,
|
||||
)
|
||||
if _, err := PostJSON(url, smsg, w.httpClient); err != nil {
|
||||
logger.Errorf("Failed to update mirror(%s) status: %s", jobMsg.name, err.Error())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (w *Worker) fetchJobStatus() []MirrorStatus {
|
||||
var mirrorList []MirrorStatus
|
||||
|
Loading…
x
Reference in New Issue
Block a user