From 3fcebb527bae05b05c90574a95bfc22f3fa1d50e Mon Sep 17 00:00:00 2001 From: Alathreon Date: Thu, 1 Aug 2024 23:57:35 +0200 Subject: [PATCH 1/2] [enhancement/readme] Improved readme --- README.md | 42 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index d5299a6..7c2ff9b 100644 --- a/README.md +++ b/README.md @@ -2,14 +2,37 @@ ## Prerequisites - Java 21 - Docker +## Used technologies +Technologies used in this project, and so technologies that you should know before contributing. +- Java +- Spring +- Gradle +- Docker (knowing Docker is the most important thing in this project) # Structure of the project -There are two projects, JShellAPI and JShellWrapper -JShellAPI is a REST API, and whenever some code is received, it will create a session, by creating a docker container, which will run JShellWrapper inside and then execute the given code in JShellWrapper. +There are two projects, JShellAPI and JShellWrapper. + +JShellAPI is a REST API, where whenever some code is received, it will create a session, by creating a docker container, which will run JShellWrapper inside and then execute the given code. + +There are three unrelated ways to run JShellPlaygroundBackend: +- [JShellWrapper alone](#how-to-use-jshellwrapper-alone-in-local) in case you specifically want to improve or debug the wrapper +- [JShellAPI in local](#how-to-use-jshellapi) in case you specifically want to improve or debug the API +- [JShellAPI in docker](#how-to-build-jshellapi-and-run-it-in-docker) in case you want to run it like it is used in production, which can be important, because the API needs to create containers from docker inside itself ## How to use JShellWrapper alone in local +This is only useful if your intent is to run the wrapper alone, without the API, for example if you want to improve the wrapper or debug it. +### From console +* Set the environment variable `evalTimeoutSeconds=15` and `sysOutCharLimit=1024` +* * On `Windows CMD`, use `set evalTimeoutSeconds=15 && set sysOutCharLimit=1024` +* * On `Windows Powershell`, use `$env:evalTimeoutSeconds=15 && $env:sysOutCharLimit=1024` +* * On `Linux Shell`, use `export evalTimeoutSeconds=15 && export sysOutCharLimit=1024` +* Run `./gradlew JShellWrapper:run` +* Alternatively, run: +* * On `Windows CMD`, `set evalTimeoutSeconds=15 && set sysOutCharLimit=1024 gradlew JShellWrapper:run` +* * On `Windows Powershell`, `$env:evalTimeoutSeconds=15 && $env:sysOutCharLimit=1024 ./gradlew JShellWrapper:run` +* * On `Linux Shell`, `evalTimeoutSeconds=15 sysOutCharLimit=1024 ./gradlew JShellWrapper:run` ### From IntelliJ -- Go in Run → Run... → Edit Configurations → create a configuration +- Go in Run → Run... → Edit Configurations → create a gradle configuration - Select the command `JShellWrapper:run` - Click on modify options, and check `VM options` - Then add `evalTimeoutSeconds=15;sysOutCharLimit=1024` in the VM options @@ -26,9 +49,9 @@ JShellAPI is a REST API, and whenever some code is received, it will create a se - Run `JShellWrapper:jibDockerBuild` to build the image - Run `bootRun` -# How to build JShellAPI in and run it in Docker +# How to build JShellAPI and run it in Docker - Launch Docker -- Run `jibDockerBuild` to create the image +- Run `./gradlew jibDockerBuild` to create the image - Create a folder outside the project - `cd` to this folder - Copy `docker-compose.yaml` inside it @@ -45,5 +68,12 @@ JShellAPI is a REST API, and whenever some code is received, it will create a se -application.yaml ``` -## How to use JShellApi ? +### Try JShell API +Create a session called `test` and execute `2+2` on it. +Note that the port might be different. +```shell +curl --request POST --url http://localhost:8080/jshell/eval/test --data '2+2' +``` + +### How to use JShellApi ? See [JShellAPI README](JShellAPI/README.MD) From a004e0138aae03ef5c9bffecc74a53eed110a339 Mon Sep 17 00:00:00 2001 From: Alathreon <45936420+Alathreon@users.noreply.github.com> Date: Fri, 2 Aug 2024 00:04:08 +0200 Subject: [PATCH 2/2] Added diagram in README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 7c2ff9b..0ad7a74 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,8 @@ There are two projects, JShellAPI and JShellWrapper. JShellAPI is a REST API, where whenever some code is received, it will create a session, by creating a docker container, which will run JShellWrapper inside and then execute the given code. +![JShellAPI diagram](https://github.com/user-attachments/assets/c566b8c0-cf81-4a56-8a0a-5715c33105a7) + There are three unrelated ways to run JShellPlaygroundBackend: - [JShellWrapper alone](#how-to-use-jshellwrapper-alone-in-local) in case you specifically want to improve or debug the wrapper - [JShellAPI in local](#how-to-use-jshellapi) in case you specifically want to improve or debug the API