Skip to content

Commit 37ddeb1

Browse files
authored
Update README.md
1 parent dfd06a1 commit 37ddeb1

File tree

1 file changed

+51
-18
lines changed

1 file changed

+51
-18
lines changed

README.md

Lines changed: 51 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,61 @@
33
- Java 19
44
- Docker
55

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
1011
### From IntelliJ
11-
- Open IntelliJ on the project JShellWrapper
1212
- 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
1416
- Press the run button
15-
## How to use JShellWrapper with JShellApi
17+
![image](https://github.com/Together-Java/JShellPlaygroundBackend/assets/45936420/01821444-b30f-4f3b-9c23-adda5a3376ae)
18+
19+
## How to use JShellAPI
1620
### 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`
2024
### 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.
2861

2962
## How to use JShellApi ?
30-
See [GUIDE.MD](JShellAPI/GUIDE.MD)
63+
See [GUIDE.MD](JShellAPI/GUIDE.MD)

0 commit comments

Comments
 (0)