Videos
The Links (updated after rename runner -> codecanvas)
Try the sandbox: https://u64.cam/codecanvas
Source code: https://github.com/camerondurham/codecanvas
TLDR
Runner is a simple server, CLI and frontend to run C++, Node.js, and Python code in a lightly isolated sandbox. I'm open to feedback/critique/questions/contributions, so feel free to pile on!
Usage
The project is deployed here to try out: https://u64.cam/runner
I've added a Makefile to run the server locally along with development instructions if anyone's interested.
Disclaimer: The server's been up since last deployment (65 days) but I can't promise it will hold up to too much abuse. Apologies if it crashes now.
Implementation
The server runs code from users in a small sandbox with limited CPU, stack size, file size, child processes and a set timeout (see code runner). FWIW, the project has 5 direct dependencies: cobra, chi, cors, mock and , x/sys.
The project mainly uses unix setrlimit to restrict user code. On server initialization, a bunch of tmp directories and users are setup to run user code and the engine round-robins these users to run code.
Some fun things about this project:
getting integration tests mostly to work in CI
using Fly.io was super easy, 10/10 would recommend especially for simple projects like this
learning about Unix rlimit syscalls and getting them to work (see process/main.go and limiter.go)
using Go for the project helped me iterate pretty quickly and get something working E2E faster than I expected
Some things I'm not proud of are:
the amount of shell script glue I had to write to get it to work
the fact that I have to spawn a child process with
cmd.Run()to get the process limiting logic to work as expectedthe slow frontend UI load time
The name is pretty unimaginative
Feedback
Please do feel free to give me honest feedback. I am always open to hearing how I could have done better and appreciate your time looking at it.
I do acknowledge this is a toy project and has been done a million times (e.g. see engineer-man/piston for a much more feature complete implementation). I'll still take that criticism or ref's to better implementations.
Contributions?
I'll still try to respond to PR's to improve things if someone wants to contribute but cannot promise any response SLA :)
However, I'm no longer actively developing this since honestly I think most of the fun part of the project is done.
Privacy Disclaimer
Your code is logged on the server side which is subject to fly.io's log retention times (I really should fix this). Your source code is deleted from the server immediately after being executed, should live on the server for like 1-2s at most.
Acks
This does not represent my employer in any capacity and is just a hobby project I built for fun.
The project was to build a somewhat multi-tenant system and was inspired by engineer-man/piston(the server behind the "I Run Code" discord bot). I built it when I was bored with work projects with some former classmates.
Edit 1: formatting Edit 2: rename project to codecanvas from runner