This is repository with controller, that receives solutions from RATS backend and tests it.
This project is using sunwalker-box as sandbox. Actually, I'm not sure how sunwalker-box working inside, but currently this controller has to be run as root.
- Rust
- sunwalker-box (added to
$PATH)
- Clone this repository
$ cargo build --release- Find compiled file at target/release/runner-controller
Example of configuration can be found in config.yaml
Unfortunately, language list is hardcoded, but you can easily change it and recompile:
- Go to src/structs/languages.rs
- Add or remove languages
languages.insert("{key}", Language {
filename: "{filename}",
compilible: {compilible},
compile_command: vec![{compile comand}],
execute_command: vec![{execute command}]
});
{key}-- language id (the same as at backend){filename}-- where will be source code file located, eg.solution.py{compilible}--true, if this language is compiled language. Elsefalse{compile command}-- array with command to compile source code and put it into/space/a.out. Each arguments should be string and the first is the full path to compiler on your server. Eg."/usr/bin/rustc", "-o", "/space/a.out", "/space/solution.rs". If this is not compiled language -- leave empty{execute command}-- array with command to execute source code, like{compile command}. Eg."/usr/bin/python", "/space/solution.py". If the language is compiled, put"/space/a.out"
π₯ Queue service location
Queue service location is configured through config.yaml
queue_url-- url of your queue service instance (required)verdicts_return_url-- url, where verdicts should be send (required)queue_poll_interval-- how many seconds to wait between requests to queue (default is 10)
Which CPU cores should be used for testing. This cores will be isolated
cores-- list of numbers of CPU cores (indexing starts from 0) (required)
sunwalker_path-- path to your compiled sunwalker file (default value issunwalker_box, that means, that sunwalker_box added to path)root-- path to directory, that will be root for sandbox (probably chroot with installed languages from language list) (default/)
To run this app you must to have sunwalker-box built and added to your path. Also, config.yaml must be located in your working directory and because this program starts sunwalker-box, it have to be started as root too.
./runner-controllerThis code does not implement freeing cores after stopping, so you have to run
sunwalker_box free --core {core}for every core in config.yaml. If you're restarting this program, you don't need to do this.
- compiling
- running compiled code
- catching exceeding limits
- checking output
- configuration files (partially, supported languages are hardcoded (but can be easely edited at src/structs/languages.rs))
- connection to backend with tasks
-
comments(nevermind)