Merge branch 'master' into bun-1.1.20
This commit is contained in:
commit
c91b8645de
|
@ -1,5 +1,21 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
CGROUP_FS="/sys/fs/cgroup"
|
||||||
|
if [ ! -e "$CGROUP_FS" ]; then
|
||||||
|
echo "Cannot find $CGROUP_FS. Please make sure your system is using cgroup v2"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -e "$CGROUP_FS/unified" ]; then
|
||||||
|
echo "Combined cgroup v1+v2 mode is not supported. Please make sure your system is using pure cgroup v2"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -e "$CGROUP_FS/cgroup.subtree_control" ]; then
|
||||||
|
echo "Cgroup v2 not found. Please make sure cgroup v2 is enabled on your system"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
cd /sys/fs/cgroup && \
|
cd /sys/fs/cgroup && \
|
||||||
mkdir isolate/ && \
|
mkdir isolate/ && \
|
||||||
echo 1 > isolate/cgroup.procs && \
|
echo 1 > isolate/cgroup.procs && \
|
||||||
|
|
38
readme.md
38
readme.md
|
@ -114,6 +114,10 @@ POST https://emkc.org/api/v2/piston/execute
|
||||||
git clone https://github.com/engineer-man/piston
|
git clone https://github.com/engineer-man/piston
|
||||||
```
|
```
|
||||||
|
|
||||||
|
> [!NOTE]
|
||||||
|
>
|
||||||
|
> Ensure the repository is cloned with LF line endings
|
||||||
|
|
||||||
### Installation
|
### Installation
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
|
@ -320,6 +324,40 @@ Content-Type: application/json
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Interactive execution endpoint (not available through the public API)
|
||||||
|
|
||||||
|
To interact with running processes in real time, you can establish a WebSocket connection at `/api/v2/connect`. This allows you to both receive output and send input to active processes.
|
||||||
|
|
||||||
|
Each message is structured as a JSON object with a `type` key, which indicates the action to perform. Below is a list of message types, their directions, and descriptions:
|
||||||
|
|
||||||
|
- **init** (client -> server): Initializes a job with the same parameters as the `/execute` endpoint, except that stdin is discarded.
|
||||||
|
- **runtime** (server -> client): Provides details on the runtime environment, including the version and language.
|
||||||
|
- **stage** (server -> client): Indicates the current execution stage, either "compile" or "run."
|
||||||
|
- **data** (server <-> client): Exchanges data between the client and server, such as stdin, stdout, or stderr streams.
|
||||||
|
- **signal** (client -> server): Sends a signal (e.g., for termination) to the running process, whether it's in the "compile" or "run" stage.
|
||||||
|
- **exit** (server -> client): Signals the end of a stage, along with the exit code or signal.
|
||||||
|
- **error** (server -> client): Reports an error, typically right before the WebSocket is closed.
|
||||||
|
|
||||||
|
An example of this endpoint in use is depicted below (**<** = client to server, **>** = server to client)
|
||||||
|
|
||||||
|
1. Client establishes WebSocket connection to `/api/v2/connect`
|
||||||
|
2. **<** `{"type":"init", "language":"bash", "version":"*", "files":[{"content": "cat"}]}`
|
||||||
|
3. **>** `{"type":"runtime","language": "bash", "version": "5.1.0"}`
|
||||||
|
4. **>** `{"type":"stage", "stage":"run"}`
|
||||||
|
5. **<** `{"type":"data", "stream":"stdin", "data":"Hello World!"}`
|
||||||
|
6. **>** `{"type":"data", "stream":"stdout", "data":"Hello World!"}`
|
||||||
|
7. _time passes_
|
||||||
|
8. **>** `{"type":"exit", "stage":"run", "code":null, "signal": "SIGKILL"}`
|
||||||
|
|
||||||
|
Errors may return status codes as follows:
|
||||||
|
|
||||||
|
- **4000: Already Initialized**: Sent when a second `init` command is issued.
|
||||||
|
- **4001: Initialization Timeout**: No `init` command was sent within 1 second of connection.
|
||||||
|
- **4002: Notified Error**: A fatal error occurred, and an `error` packet was transmitted.
|
||||||
|
- **4003: Not yet Initialized**: A non-`init` command was sent without a job context.
|
||||||
|
- **4004: Can only write to stdin**: The client attempted to write to a stream other than stdin.
|
||||||
|
- **4005: Invalid Signal**: An invalid signal was sent in a `signal` packet.
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
# Supported Languages
|
# Supported Languages
|
||||||
|
|
Loading…
Reference in New Issue