diff --git a/api/src/api/v2.js b/api/src/api/v2.js index e3e0522..215453b 100644 --- a/api/src/api/v2.js +++ b/api/src/api/v2.js @@ -146,7 +146,7 @@ router.ws('/connect', async (ws, req) => { eventBus.on("exit", (stage, status) => ws.send(JSON.stringify({type: "exit", stage, ...status}))) ws.on("message", async (data) => { - + try{ const msg = JSON.parse(data); @@ -194,7 +194,7 @@ router.ws('/connect', async (ws, req) => { } break; } - + }catch(error){ ws.send(JSON.stringify({type: "error", message: error.message})) ws.close(4002, "Notified Error") diff --git a/api/src/job.js b/api/src/job.js index ecc4ab3..712dcd8 100644 --- a/api/src/job.js +++ b/api/src/job.js @@ -146,31 +146,26 @@ class Job { const kill_timeout = set_timeout( - async _ => { - logger.info(`Timeout exceeded timeout=${timeout} uuid=${this.uuid}`) - process.kill(proc.pid, 'SIGKILL') - }, + _ => proc.kill('SIGKILL'), timeout ); - proc.stderr.on('data', async data => { + proc.stderr.on('data', data => { if(eventBus !== null) { eventBus.emit("stderr", data); } else if (stderr.length > config.output_max_size) { - logger.info(`stderr length exceeded uuid=${this.uuid}`) - process.kill(proc.pid, 'SIGKILL') + proc.kill('SIGKILL'); } else { stderr += data; output += data; } }); - proc.stdout.on('data', async data => { + proc.stdout.on('data', data => { if(eventBus !== null){ eventBus.emit("stdout", data); } else if (stdout.length > config.output_max_size) { - logger.info(`stdout length exceeded uuid=${this.uuid}`) - process.kill(proc.pid, 'SIGKILL') + proc.kill('SIGKILL'); } else { stdout += data; output += data; @@ -184,7 +179,6 @@ class Job { proc.stdout.destroy(); await this.cleanup_processes() - logger.debug(`Finished exit cleanup uuid=${this.uuid}`) }; proc.on('exit', async (code, signal) => { @@ -290,47 +284,36 @@ class Job { this.state = job_states.EXECUTED; } - async cleanup_processes(dont_wait = []) { + async cleanup_processes() { let processes = [1]; - logger.debug(`Cleaning up processes uuid=${this.uuid}`) while (processes.length > 0) { - processes = [] + processes = await new Promise((resolve, reject) => + cp.execFile('ps', ['awwxo', 'pid,ruid'], (err, stdout) => { + if (err === null) { + const lines = stdout.split('\n').slice(1); //Remove header with slice + const procs = lines.map(line => { + const [pid, ruid] = line + .trim() + .split(/\s+/) + .map(n => parseInt(n)); + return { pid, ruid }; + }); - const proc_ids = await fs.readdir("/proc"); - - - processes = await Promise.all(proc_ids.map(async (proc_id) => { - if(isNaN(proc_id)) return -1; - try{ - const proc_status = await fs.read_file(path.join("/proc",proc_id,"status")); - const proc_lines = proc_status.to_string().split("\n") - const uid_line = proc_lines.find(line=>line.starts_with("Uid:")) - const [_, ruid, euid, suid, fuid] = uid_line.split(/\s+/); - - - if(ruid == this.uid || euid == this.uid) - return parse_int(proc_id) - - }catch{ - return -1 - } - - return -1 - })) - - processes = processes.filter(p => p > 0) - - if(processes.length > 0) - logger.debug(`Got processes to kill: ${processes} uuid=${this.uuid}`) - + resolve(procs); + } else { + reject(error); + } + }) + ); + processes = processes.filter(proc => proc.ruid === this.uid); for (const proc of processes) { // First stop the processes, but keep their resources allocated so they cant re-fork try { - process.kill(proc, 'SIGSTOP'); + process.kill(proc.pid, 'SIGSTOP'); } catch { // Could already be dead } @@ -339,17 +322,14 @@ class Job { for (const proc of processes) { // Then clear them out of the process tree try { - process.kill(proc, 'SIGKILL'); + process.kill(proc.pid, 'SIGKILL'); } catch { // Could already be dead and just needs to be waited on } - if(!dont_wait.includes(proc)) - wait_pid(proc); + wait_pid(proc.pid); } } - - logger.debug(`Cleaned up processes uuid=${this.uuid}`) } async cleanup_filesystem() { diff --git a/cli/package-lock.json b/cli/package-lock.json index 335ed21..f7c2771 100644 --- a/cli/package-lock.json +++ b/cli/package-lock.json @@ -1,12 +1,12 @@ { "name": "piston-cli", - "version": "1.1.0", + "version": "1.0.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "piston-cli", - "version": "1.1.0", + "version": "1.0.0", "license": "MIT", "dependencies": { "axios": "^0.21.2", diff --git a/packages/CONTRIBUTING.MD b/packages/CONTRIBUTING.MD index b1ed6d3..813f71e 100644 --- a/packages/CONTRIBUTING.MD +++ b/packages/CONTRIBUTING.MD @@ -2,7 +2,7 @@ ## Naming Languages -Languages should be named after their interpreters, and the command line binaries you call. The language version should use semantic versioning. +Languages should be named after their interpreters, and the command line binaries you call. For example, the full name of the standard python interpreter is `CPython`, however we would name it `python`, after the main binary which it provides. In the example of NodeJS, we would call this `node`, after the main binary. diff --git a/packages/iverilog/11.0.0/build.sh b/packages/iverilog/11.0.0/build.sh deleted file mode 100755 index befb2fa..0000000 --- a/packages/iverilog/11.0.0/build.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash - -PREFIX=$(realpath $(dirname $0)) - -mkdir -p build/iverilog -cd build/iverilog -curl -L https://github.com/steveicarus/iverilog/archive/refs/tags/v11_0.tar.gz -o iverilog.tar.gz -tar xzf iverilog.tar.gz --strip-components=1 - -chmod +x ./autoconf.sh -./autoconf.sh -./configure --prefix="$PREFIX" -make -j$(nproc) -make install -j$(nproc) - -cd ../../ -rm -rf build diff --git a/packages/iverilog/11.0.0/compile b/packages/iverilog/11.0.0/compile deleted file mode 100644 index 56f4b4e..0000000 --- a/packages/iverilog/11.0.0/compile +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -rename 's/$/\.v/' "$@" # Add .v extension -iverilog *.v diff --git a/packages/iverilog/11.0.0/environment b/packages/iverilog/11.0.0/environment deleted file mode 100644 index b482830..0000000 --- a/packages/iverilog/11.0.0/environment +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -export PATH=$PWD/bin:$PATH diff --git a/packages/iverilog/11.0.0/metadata.json b/packages/iverilog/11.0.0/metadata.json deleted file mode 100644 index 5a35bde..0000000 --- a/packages/iverilog/11.0.0/metadata.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "language": "iverilog", - "version": "11.0.0", - "aliases": ["verilog", "vvp"] -} diff --git a/packages/iverilog/11.0.0/run b/packages/iverilog/11.0.0/run deleted file mode 100644 index 39e898c..0000000 --- a/packages/iverilog/11.0.0/run +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -shift -vvp a.out "$@" diff --git a/packages/iverilog/11.0.0/test.verilog b/packages/iverilog/11.0.0/test.verilog deleted file mode 100644 index 88fcd7a..0000000 --- a/packages/iverilog/11.0.0/test.verilog +++ /dev/null @@ -1,7 +0,0 @@ -module hello; - initial - begin - $display("OK"); - $finish ; - end -endmodule diff --git a/packages/sqlite3/3.36.0/build.sh b/packages/sqlite3/3.36.0/build.sh deleted file mode 100755 index 18d5b8f..0000000 --- a/packages/sqlite3/3.36.0/build.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash -PREFIX=$(realpath $(dirname $0)) - -curl https://www.sqlite.org/2021/sqlite-amalgamation-3360000.zip -o sqlite.zip -unzip -q sqlite.zip -rm -rf sqlite.zip - -gcc -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION sqlite-amalgamation-3360000/shell.c sqlite-amalgamation-3360000/sqlite3.c -o sqlite3 - -rm -rf sqlite-amalgamation-3360000 diff --git a/packages/sqlite3/3.36.0/environment b/packages/sqlite3/3.36.0/environment deleted file mode 100644 index 50242cc..0000000 --- a/packages/sqlite3/3.36.0/environment +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -export PATH=$PWD:$PATH diff --git a/packages/sqlite3/3.36.0/metadata.json b/packages/sqlite3/3.36.0/metadata.json deleted file mode 100644 index d531aaf..0000000 --- a/packages/sqlite3/3.36.0/metadata.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "language": "sqlite3", - "version": "3.36.0", - "aliases": ["sqlite", "sql"] -} diff --git a/packages/sqlite3/3.36.0/run b/packages/sqlite3/3.36.0/run deleted file mode 100644 index 8484f3d..0000000 --- a/packages/sqlite3/3.36.0/run +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -sqlite3 < "$1" diff --git a/packages/sqlite3/3.36.0/test.sql b/packages/sqlite3/3.36.0/test.sql deleted file mode 100644 index 3a3c57b..0000000 --- a/packages/sqlite3/3.36.0/test.sql +++ /dev/null @@ -1 +0,0 @@ -SELECT 'OK'; diff --git a/piston b/piston index a14e7f5..28e18db 100755 --- a/piston +++ b/piston @@ -19,7 +19,6 @@ case $1 in echo "Commands:" echo " select Select the environment" echo " docker_compose Interact directly with the docker-compose for the selected environment" - echo " logs Show docker-compose logs" echo echo " start Starts piston" echo " stop Stops piston" @@ -38,19 +37,18 @@ case $1 in echo " clean-repo Remove all packages from local repo" echo " build-pkg Build a package" echo " rebuild Build and restart the docker container" - + else echo " Switch to developement environment for more info" echo " > piston select dev" - + fi ;; select) echo "$2" > .piston_env ;; docker_compose) shift; docker_compose "$@";; - logs) docker_compose logs -f ;; restart) docker_compose restart ;; start) docker_compose up -d ;; diff --git a/readme.md b/readme.md index c942624..a154fe6 100644 --- a/readme.md +++ b/readme.md @@ -42,10 +42,10 @@
# Notes About Hacktoberfest - + While we are accepting pull requests for Hacktoberfest, we will reject any low-quality PRs. If we see PR abuse for Hacktoberfest, we will stop providing Hacktoberfest approval for pull requests. - + We are accepting PRs for: * Packages - updating package versions, adding new packages * Documentation updates @@ -343,7 +343,6 @@ Content-Type: application/json `golfscript`, `groovy`, `haskell`, -`iverilog`, `java`, `javascript`, `jelly`, @@ -375,7 +374,6 @@ Content-Type: application/json `ruby`, `rust`, `scala`, -`sqlite3`, `swift`, `typescript`, `basic`, diff --git a/repo/Dockerfile b/repo/Dockerfile index de28c11..56ca59d 100644 --- a/repo/Dockerfile +++ b/repo/Dockerfile @@ -9,7 +9,7 @@ RUN apt-get update && apt-get install -y unzip autoconf build-essential libssl-d libncursesw5-dev python3-pip libgmp-dev libmpfr-dev python2 libffi-dev gfortran\ libreadline-dev libblas-dev liblapack-dev libpcre3-dev libarpack2-dev libfftw3-dev \ libglpk-dev libqhull-dev libqrupdate-dev libsuitesparse-dev libsundials-dev \ - libbz2-dev liblzma-dev libpcre2-dev gperf bison flex g++ && \ + libbz2-dev liblzma-dev libpcre2-dev && \ ln -sf /bin/bash /bin/sh && \ rm -rf /var/lib/apt/lists/* && \ update-alternatives --install /usr/bin/python python /usr/bin/python3.7 2