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
@ -54,9 +54,10 @@ type globalConfig struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type managerConfig struct {
|
type managerConfig struct {
|
||||||
APIBase string `toml:"api_base"`
|
APIBase string `toml:"api_base"`
|
||||||
CACert string `toml:"ca_cert"`
|
CACert string `toml:"ca_cert"`
|
||||||
Token string `toml:"token"`
|
ExtraStatusAPIs []string `toml:"extra_status_managers"`
|
||||||
|
// Token string `toml:"token"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type serverConfig struct {
|
type serverConfig struct {
|
||||||
|
@ -405,12 +405,6 @@ func (w *Worker) registorWorker() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (w *Worker) updateStatus(job *mirrorJob, jobMsg jobMessage) {
|
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
|
p := job.provider
|
||||||
smsg := MirrorStatus{
|
smsg := MirrorStatus{
|
||||||
Name: jobMsg.name,
|
Name: jobMsg.name,
|
||||||
@ -422,8 +416,15 @@ func (w *Worker) updateStatus(job *mirrorJob, jobMsg jobMessage) {
|
|||||||
ErrorMsg: jobMsg.msg,
|
ErrorMsg: jobMsg.msg,
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := PostJSON(url, smsg, w.httpClient); err != nil {
|
apiBases := []string{w.cfg.Manager.APIBase}
|
||||||
logger.Errorf("Failed to update mirror(%s) status: %s", jobMsg.name, err.Error())
|
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())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user