From e460f396e307251a6cce828cbb6acec248f98825 Mon Sep 17 00:00:00 2001 From: Arnab-Afk Date: Fri, 21 Mar 2025 22:39:32 +0530 Subject: [PATCH] Backend Changes and Readme update --- Readme.md | 22 ++++++++++++++++++++++ backend/service/execution.go | 2 +- backend/tmp/main.exe | Bin 8203776 -> 8203776 bytes 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 Readme.md diff --git a/Readme.md b/Readme.md new file mode 100644 index 0000000..84f49a0 --- /dev/null +++ b/Readme.md @@ -0,0 +1,22 @@ +# Monaco Code Execution Engine +Monaco is a secure, containerized code execution engine that allows you to run code in multiple programming languages through a simple REST API. + +## Features +- Multi-language support: Run code in Python, Java, C, and C++ +- Secure execution: All code runs in isolated Docker containers +- Resource limits: Memory, CPU, and file descriptor limits to prevent abuse +- Concurrent processing: Efficient job queue for handling multiple requests +- Simple REST API: Easy to integrate with any frontend + +## Architecture +Monaco consists of several components: + +- HTTP Handlers (handler/handler.go): Processes API requests +- Execution Service (service/execution.go): Manages code execution in containers +- Job Queue (queue/queue.go): Handles concurrent execution of code submissions +- Submission Model (model/submission.go): Defines the data structure for code submissions + +## Requirements +- Go 1.22.3 or higher +- Docker +- Network connectivity for container image pulling \ No newline at end of file diff --git a/backend/service/execution.go b/backend/service/execution.go index 7097ff7..90fc2a5 100644 --- a/backend/service/execution.go +++ b/backend/service/execution.go @@ -232,7 +232,7 @@ func (s *ExecutionService) executeC(submission *model.CodeSubmission) { "gcc:latest", "bash", "-c", "cd /code && gcc -o main main.c && ./main") log.Printf("[C-%s] Executing C code with timeout: 10s", submission.ID) - output, err := s.executeWithTimeout(cmd, 1000*time.Second, submission.ID) + output, err := s.executeWithTimeout(cmd, 10*time.Second, submission.ID) elapsed := time.Since(startTime) log.Printf("[C-%s] C execution completed in %v", submission.ID, elapsed) diff --git a/backend/tmp/main.exe b/backend/tmp/main.exe index ea60ef9dcdb36b42ccb095e1ed6619202c6a3023..5e1b8a0b3bf8e9ae7e8e601512b90f420c60484b 100644 GIT binary patch delta 731 zcmbWxJ6F?S0LJknU{UabcR*0Y3n*fmkhFd4tss`FH57;~A_$~;18r@!)QX7?Ime+R z0|Otz#jR^MS0^Vn{0JUr|9%CB-!nYZKiL1>9^hL~D4ULqo1W!(Sy8vP(t6!VZ8%D8 zJ1I=BFjHKJO;@W0X%?+nrLwfXI+;lsIT@Yb6dBtq7Z(*hYbQ;imBdu3=H^Oez2f`B zT|>KTO8=K2)CfX{(1vz&;4uFEoj8J{=t4J+;W$p6}-kO*02s6c{q@8v4Kq#P(%rDP(}rB@eWmNp@#RU;{&$w5gvSeY9`#zt?z#U Do75FD delta 731 zcmbWxxmFWl06^iRU{KuRt_X^Vf?}M^Oy>V5Q8Xb!21Ju!%;o}1-`LR&+EzfXCYFD_DHZt**QKyT`>>uP2={Qt9lJqs7z3H8E#cGQK{e zwB~D(=CrSxOBNEkFJ@-z^`O$o+l!HeWn{{7p%P3KHtN-^Vl^twm1sU^$yhC!SzS(< zQGKL;cza11_~d%pu4ffPcLY2XP4fIE*7WieoqqFHYbjPT@4p;4IGJJT71W z7cqz-T*74x;|fM_6{EO@>mAoK_Gh=(`}xPOc5818%w%Gd#x&yu>1wV55K{N+`p@GAdX>6|Yc39Sy8v4X@F}8?56k-r+qyU;`~|cEZlb G?zg}AIS|(X