remove k8s configs, update worker for multi-languages support, add local-submit option
This commit is contained in:
@@ -23,16 +23,63 @@ public class TestController : ControllerBase
|
||||
|
||||
try
|
||||
{
|
||||
// Save package to temporary file before starting background task
|
||||
// This is necessary because IFormFile becomes unavailable after request completes
|
||||
string? packageFilePath = null;
|
||||
if (request.Package != null)
|
||||
{
|
||||
var tempDirectory = Path.Combine(Path.GetTempPath(), "worker-packages");
|
||||
Directory.CreateDirectory(tempDirectory);
|
||||
|
||||
packageFilePath = Path.Combine(tempDirectory, $"package_{Guid.NewGuid()}.zip");
|
||||
|
||||
await using (var fileStream = new FileStream(packageFilePath, FileMode.Create, FileAccess.Write, FileShare.None))
|
||||
{
|
||||
await request.Package.CopyToAsync(fileStream);
|
||||
}
|
||||
|
||||
_logger.LogInformation("Package saved to temporary file: {FilePath}", packageFilePath);
|
||||
}
|
||||
|
||||
// Create a copy of request data for background task
|
||||
var backgroundRequest = new TestRequest
|
||||
{
|
||||
Id = request.Id,
|
||||
MissionId = request.MissionId,
|
||||
Language = request.Language,
|
||||
LanguageVersion = request.LanguageVersion,
|
||||
SourceCode = request.SourceCode,
|
||||
CallbackUrl = request.CallbackUrl,
|
||||
Package = null, // Will use file path instead
|
||||
PackageFilePath = packageFilePath
|
||||
};
|
||||
|
||||
// Start testing in background
|
||||
_ = Task.Run(async () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
await _testingService.ProcessSubmitAsync(request);
|
||||
await _testingService.ProcessSubmitAsync(backgroundRequest);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error processing submit {SubmitId}", request.Id);
|
||||
_logger.LogError(ex, "Error processing submit {SubmitId}", backgroundRequest.Id);
|
||||
}
|
||||
finally
|
||||
{
|
||||
// Cleanup temporary package file
|
||||
if (packageFilePath != null && System.IO.File.Exists(packageFilePath))
|
||||
{
|
||||
try
|
||||
{
|
||||
System.IO.File.Delete(packageFilePath);
|
||||
_logger.LogInformation("Deleted temporary package file: {FilePath}", packageFilePath);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "Failed to delete temporary package file: {FilePath}", packageFilePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -48,7 +95,7 @@ public class TestController : ControllerBase
|
||||
[HttpGet("health")]
|
||||
public IActionResult Health()
|
||||
{
|
||||
return Ok(new { status = "healthy", service = "cpp-worker", timestamp = DateTime.UtcNow });
|
||||
return Ok(new { status = "healthy", service = "universal-worker", timestamp = DateTime.UtcNow });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,4 +108,5 @@ public class TestRequest
|
||||
public string SourceCode { get; set; } = string.Empty;
|
||||
public string CallbackUrl { get; set; } = string.Empty;
|
||||
public IFormFile? Package { get; set; }
|
||||
public string? PackageFilePath { get; set; } // Internal use - path to saved package file
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user