Bump version to 1.0.9
Fix Wake-on-LAN: set SO_BROADCAST on UDP socket, send 3 magic packets, expose broadcast_addr and wake timeout fields in UI, add Test Wake endpoint, surface send errors in job status, bump default wake timeout to 180s.
This commit is contained in:
@@ -136,20 +136,26 @@ func (e *Engine) Run(ctx context.Context, jobID int64, pairID int64) error {
|
||||
if targetMachine.BroadcastAddr != nil {
|
||||
bcast = *targetMachine.BroadcastAddr
|
||||
}
|
||||
if err := wol.Send(targetMachine.Host, mac, bcast); err != nil {
|
||||
slog.Warn("WoL failed", "host", targetMachine.Host, "error", err)
|
||||
wolErr := wol.Send(mac, bcast)
|
||||
if wolErr != nil {
|
||||
slog.Warn("WoL send failed", "host", targetMachine.Host, "error", wolErr)
|
||||
} else {
|
||||
slog.Info("WoL magic packet sent", "host", targetMachine.Host, "mac", *targetMachine.MACAddress)
|
||||
}
|
||||
|
||||
timeout := time.Duration(targetMachine.WakeTimeoutSeconds) * time.Second
|
||||
interval := time.Duration(targetMachine.WakeCheckIntervalSeconds) * time.Second
|
||||
if err := wol.WaitUntilReady(jobCtx, targetMachine.Host, remotePort, timeout, interval, false); err != nil {
|
||||
e.setJobStatus(jobID, "failed")
|
||||
e.setJobError(jobID, "wol_timeout", err.Error())
|
||||
e.emit(Event{Type: "status", JobID: jobID, Key: "status", Value: "failed", Line: err.Error()})
|
||||
return fmt.Errorf("machine not ready: %w", err)
|
||||
}
|
||||
if err := wol.WaitUntilReady(jobCtx, targetMachine.Host, remotePort, timeout, interval); err != nil {
|
||||
e.setJobStatus(jobID, "failed")
|
||||
if wolErr != nil {
|
||||
e.setJobError(jobID, "wol_send_failed", wolErr.Error())
|
||||
e.emit(Event{Type: "status", JobID: jobID, Key: "status", Value: "failed", Line: fmt.Sprintf("WoL send failed: %v", wolErr)})
|
||||
return fmt.Errorf("WoL send failed: %w", wolErr)
|
||||
}
|
||||
e.setJobError(jobID, "wol_timeout", err.Error())
|
||||
e.emit(Event{Type: "status", JobID: jobID, Key: "status", Value: "failed", Line: err.Error()})
|
||||
return fmt.Errorf("machine not ready: %w", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user