|
@@ -551,6 +551,16 @@ public:
|
|
|
job.errorMessage = jobJson["error_message"];
|
|
job.errorMessage = jobJson["error_message"];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // Clean up stale processing jobs from server restart
|
|
|
|
|
+ if (job.status == GenerationStatus::PROCESSING) {
|
|
|
|
|
+ job.status = GenerationStatus::FAILED;
|
|
|
|
|
+ job.errorMessage = "Server restarted while job was processing";
|
|
|
|
|
+ job.endTime = std::chrono::steady_clock::now();
|
|
|
|
|
+ std::cout << "Marked stale job as failed: " << job.id << std::endl;
|
|
|
|
|
+ // Persist updated status to disk
|
|
|
|
|
+ saveJobToFile(job);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// Add to active jobs
|
|
// Add to active jobs
|
|
|
std::lock_guard<std::mutex> lock(jobsMutex);
|
|
std::lock_guard<std::mutex> lock(jobsMutex);
|
|
|
activeJobs[job.id] = job;
|
|
activeJobs[job.id] = job;
|