Add SSH key management, job history persistence, and live streaming

- SSH key management: generate ed25519 keypairs or import public keys
  from UI (/ssh-keys), per-machine key selection in Machines form,
  one-time private key download with hash verification
- Fix engine to use machine-specific SSH key (was hardcoded to server key)
- Job log persistence: write to job_logs table (DB) with batched inserts,
  buffer of 50 lines; GetAllFiltered with status/pair/date range filters
- EventBus refactor: per-job subscriber channels, global channel, non-blocking
- SSE endpoints: /jobs/stream (all), /jobs/:id/log/stream (per-job live)
- JobDetail page: live log streaming, auto-scroll, cancel, duration
- JobHistory: filters (pair, status, date range), pagination, link to detail
- Cleanup scheduler: daily purge of job_logs and finished jobs older than
  SYNCSERVER_RETENTION_DAYS (default 30)
- Migration 0002: indexes on job_logs(job_id), jobs(status,created_at),
  jobs(sync_pair_id)
This commit is contained in:
2026-07-07 20:36:11 -04:00
parent 5374ab81cc
commit bfa006f4ab
22 changed files with 1424 additions and 136 deletions
+33 -7
View File
@@ -55,13 +55,39 @@ type SyncPairResponse struct {
}
type JobResponse struct {
ID int64 `json:"id"`
SyncPairID int64 `json:"sync_pair_id"`
TriggerType string `json:"trigger_type"`
Status string `json:"status"`
StartedAt *string `json:"started_at"`
FinishedAt *string `json:"finished_at"`
LogFile *string `json:"log_file"`
ID int64 `json:"id"`
SyncPairID int64 `json:"sync_pair_id"`
TriggerType string `json:"trigger_type"`
Status string `json:"status"`
StartedAt *string `json:"started_at"`
FinishedAt *string `json:"finished_at"`
LogFile *string `json:"log_file"`
DurationSeconds *int64 `json:"duration_seconds,omitempty"`
LogLineCount *int64 `json:"log_line_count,omitempty"`
}
type LogLineResponse struct {
ID int64 `json:"id"`
JobID int64 `json:"job_id"`
Stream string `json:"stream"`
Content string `json:"content"`
Timestamp string `json:"timestamp"`
}
type SSHKeyRequest struct {
Label string `json:"label"`
Generate bool `json:"generate"`
PublicKey string `json:"public_key"`
}
type SSHKeyResponse struct {
ID int64 `json:"id"`
Label string `json:"label"`
PublicKey string `json:"public_key"`
Fingerprint string `json:"fingerprint"`
InUse bool `json:"in_use"`
HasPrivateKey bool `json:"has_private_key"`
CreatedAt string `json:"created_at"`
}
type ErrorResponse struct {