|
3 | 3 | - Java 19 |
4 | 4 | - Docker |
5 | 5 |
|
6 | | -## How to use JShellWrapper alone |
7 | | -### From command line |
8 | | -- Run BuildJShellWrapper.bat/.sh to compile the wrapper and package it into a jar |
9 | | -- Run java -DevalTimeoutSeconds=15 -jar ./JShellWrapper/out/JShellWrapper.jar |
| 6 | +# Structure of the project |
| 7 | +There are two projects, JShellAPI and JShellWrapper |
| 8 | +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. |
| 9 | + |
| 10 | +## How to use JShellWrapper alone in local |
10 | 11 | ### From IntelliJ |
11 | | -- Open IntelliJ on the project JShellWrapper |
12 | 12 | - Go in Run → Run... → Edit Configurations → create a configuration |
13 | | -- Select the main class, the jdk, etc, click on modify options, and check VM options, then add -DevalTimeoutSeconds=15 in the VM options |
| 13 | +- Select the command `JShellWrapper:run` |
| 14 | +- Click on modify options, and check `VM options` |
| 15 | +- Then add `evalTimeoutSeconds=15;sysOutCharLimit=1024` in the VM options |
14 | 16 | - Press the run button |
15 | | -## How to use JShellWrapper with JShellApi |
| 17 | +  |
| 18 | + |
| 19 | +## How to use JShellAPI |
16 | 20 | ### From the console |
17 | | -- Run BuildJShellWrapper.bat/.sh to compile the wrapper and package it into a jar |
18 | | -- Run BuildImage.bat/.sh to build the image |
19 | | -- Run ./gradlew bootRun |
| 21 | +- Launch Docker |
| 22 | +- Run `./gradlew :JShellWrapper:jibDockerBuild` to build the image |
| 23 | +- Run `./gradlew bootRun` |
20 | 24 | ### How to build and run from IntelliJ |
21 | | -- Run BuildJShellWrapper.bat/.sh |
22 | | -- Open IntelliJ on JShellAPI |
23 | | -- Run the main class |
24 | | -### using IntelliJ instead of BuildJShellWrapper script |
25 | | -- Open IntelliJ on the project JShellWrapper |
26 | | -- Go in build → Build Artifacts... → Build |
27 | | -- The jar should be located directly under JShellWrapper/out |
| 25 | +- Launch Docker |
| 26 | +- Run `JShellWrapper:jibDockerBuild` to build the image |
| 27 | +- Run `bootRun` |
| 28 | + |
| 29 | +# How to build JShellAPI in and run it in Docker |
| 30 | +- Launch Docker |
| 31 | +- Run `jibDockerBuild` to create the image |
| 32 | +- Create a folder |
| 33 | +- Create `docker-compose.yml`: |
| 34 | + ```yml |
| 35 | +services: |
| 36 | + jshell-backend-master: |
| 37 | + image: "togetherjava.org:5001/togetherjava/jshellbackend:master" |
| 38 | + command: ["--spring.config.location=file:///home/backend/config/application.properties"] |
| 39 | + restart: always |
| 40 | + ports: |
| 41 | + - 54321:8080 |
| 42 | + - 5005:5005 |
| 43 | + environment: |
| 44 | + JAVA_TOOL_OPTIONS: "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005" |
| 45 | + volumes: |
| 46 | + - /var/run/docker.sock:/var/run/docker.sock |
| 47 | + - ./docker-config.json:/root/.docker/config.json |
| 48 | + - ./config:/home/backend/config |
| 49 | + networks: |
| 50 | + - jshell-backend |
| 51 | + |
| 52 | +networks: |
| 53 | + jshell-backend: |
| 54 | + external: true |
| 55 | + name: develop-bot |
| 56 | + ``` |
| 57 | +- Optionaly, create `config/application.properties` where you can put custom config (see the actual [application.properties](JShellAPI/src/main/resources/application.properties)) |
| 58 | +- If you don't create it, delete the `command: ["--spring.config.location=file:///home/backend/config/application.properties"]` line in the `docker-compose.yml` |
| 59 | +- Run `docker compose build` or `docker-compose build` in the folder, depending of your version of Docker. |
| 60 | +- Run `docker compose start` or `docker-compose start` in the folder, depending of your version of Docker. |
28 | 61 |
|
29 | 62 | ## How to use JShellApi ? |
30 | | -See [GUIDE.MD](JShellAPI/GUIDE.MD) |
| 63 | +See [GUIDE.MD](JShellAPI/GUIDE.MD) |
0 commit comments