myriad/README.md

83 lines
2.4 KiB
Markdown
Raw Normal View History

2019-07-09 11:19:41 +02:00
# Myriad
Arbitrary code execution server using Docker.
2020-06-17 11:05:32 +02:00
Each language has its own Docker image and so each evaluation will run in the respective language's locked-down container.
Features include:
- Building images on startup.
- Preparing containers on startup or on demand.
- Periodically cleanup running containers.
- Customizable settings for each image:
- Maximum memory usage.
- Maximum CPU usage.
- Maximum evaluation time.
- Maximum concurrent evaluations.
- Maximum number of retries.
2020-06-22 08:56:19 +02:00
- Maximum output size.
2020-06-17 11:05:32 +02:00
Requires Docker 18+ to operate.
2019-07-09 11:19:41 +02:00
2020-06-17 09:29:29 +02:00
## Download Pre-Built Binary
2020-06-17 09:24:03 +02:00
Check the `Releases` tab for pre-built binaries.
2020-06-17 09:29:29 +02:00
The languages folder and an example configuration are also included.
2020-06-17 09:24:03 +02:00
## Installation from Source
2019-07-09 11:19:41 +02:00
You can use either `stack` or `cabal`.
- `stack` should be >= 2.1.1, `cabal` should be >= 2.4.0.0.
- GHC 8.8.3 is required if not already installed by `stack` or if using `cabal`.
2019-07-11 07:00:41 +02:00
Make sure the place where `stack` or `cabal` places binaries is in your PATH.
- For `stack`, you can get it with `stack path --local-bin`.
- For `cabal`, you should find it in `$HOME/.cabal/bin` (Linux) or `%APPDATA%\cabal\bin` (Windows).
Run `stack install` or `cabal new-install` inside the project folder.
2020-06-17 09:29:29 +02:00
Or, to build within the project, run `stack build` or `cabal new-build`.
2020-06-17 11:05:32 +02:00
## Configure and Run
2020-06-17 05:46:10 +02:00
Make sure the configuration is filled out, see `config.example.yaml` for an example.
2020-06-17 09:29:29 +02:00
Run `myriad` (or `stack run` or `cabal new-run` if you built within the project) to start the server.
2020-06-17 05:46:10 +02:00
The config and languages folder will default to `./config.yaml` and `./languages`.
You can configure this with `--config` and `--languages`.
2019-07-09 11:19:41 +02:00
## Endpoints
2019-07-09 11:32:27 +02:00
### **GET** `/languages`
2019-09-05 05:53:57 +02:00
2019-07-09 11:19:41 +02:00
List of enabled languages.
Example response:
```json
["haskell", "javascript"]
```
2019-07-09 11:32:27 +02:00
### **POST** `/eval`
2019-09-05 05:53:57 +02:00
2019-07-09 11:19:41 +02:00
Evaluate code.
JSON payload with `language` and `code` keys.
2019-07-11 06:25:50 +02:00
The `language` is as in the name of a subfolder in the `languages` directory.
2019-07-09 11:19:41 +02:00
Example payload:
```json
{ "language": "haskell", "code": "main = print (1 + 1)" }
```
Example response:
```json
{ "result": "2\n" }
```
Errors with 404 if `language` is not found, `504` if evaluation timed out, or `500` if evaluation failed for other reasons.
2019-07-11 08:20:36 +02:00
### **GET** `/containers`
2019-09-05 05:53:57 +02:00
2019-07-11 08:20:36 +02:00
List of containers being handled by Myriad.
### **POST** `/cleanup`
2019-09-05 05:53:57 +02:00
2019-07-11 08:20:36 +02:00
Kill all containers, giving back the names of the containers killed.