aboutsummaryrefslogtreecommitdiff
path: root/weed/worker/worker.go
diff options
context:
space:
mode:
authorchrislu <chris.lu@gmail.com>2025-07-27 11:04:51 -0700
committerchrislu <chris.lu@gmail.com>2025-07-27 11:04:51 -0700
commit1b64a0f0344c4c1066833a6d25b20dca9bb171e5 (patch)
tree9b8d8600b7b9d8fc43127cb2878b3dc625a60427 /weed/worker/worker.go
parent9025b722410c605181b094fbeeed66de002fda27 (diff)
downloadseaweedfs-origin/worker-execute-ec-tasks.tar.xz
seaweedfs-origin/worker-execute-ec-tasks.zip
add generic logging and implement it for balancing taskorigin/worker-execute-ec-tasks
Diffstat (limited to 'weed/worker/worker.go')
-rw-r--r--weed/worker/worker.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/weed/worker/worker.go b/weed/worker/worker.go
index 8d869b2bd..3ac08a0fa 100644
--- a/weed/worker/worker.go
+++ b/weed/worker/worker.go
@@ -366,15 +366,29 @@ func (w *Worker) executeTask(task *types.Task) {
return
}
+ // Initialize task logging
+ if err := taskInstance.InitializeTaskLogging(taskWorkingDir, task.ID); err != nil {
+ glog.Warningf("Failed to initialize task logging for %s: %v", task.ID, err)
+ } else {
+ // Ensure logging is closed when task completes
+ defer taskInstance.CloseTaskLogging()
+ taskInstance.LogInfo("Worker %s starting execution of task %s (type: %s)", w.id, task.ID, task.Type)
+ if task.VolumeID != 0 {
+ taskInstance.LogInfo("Task parameters: VolumeID=%d, Server=%s, Collection=%s", task.VolumeID, task.Server, task.Collection)
+ }
+ }
+
// Execute task
err = taskInstance.Execute(taskParams)
// Report completion
if err != nil {
+ taskInstance.LogError("Task execution failed: %v", err)
w.completeTask(task.ID, false, err.Error())
w.tasksFailed++
glog.Errorf("Worker %s failed to execute task %s: %v", w.id, task.ID, err)
} else {
+ taskInstance.LogInfo("Task completed successfully")
w.completeTask(task.ID, true, "")
w.tasksCompleted++
glog.Infof("Worker %s completed task %s successfully", w.id, task.ID)