Compare commits
No commits in common. "e97b6d426d9268b1f128a6e3a51aada31e0242f2" and "90945d162135a5dd080ec6be3400ce37328b46d3" have entirely different histories.
e97b6d426d
...
90945d1621
|
@ -129,7 +129,7 @@ function get_job(body) {
|
||||||
compile_timeout = compile_timeout || rt.timeouts.compile;
|
compile_timeout = compile_timeout || rt.timeouts.compile;
|
||||||
run_timeout = run_timeout || rt.timeouts.run;
|
run_timeout = run_timeout || rt.timeouts.run;
|
||||||
compile_memory_limit = compile_memory_limit || rt.memory_limits.compile;
|
compile_memory_limit = compile_memory_limit || rt.memory_limits.compile;
|
||||||
run_memory_limit = run_memory_limit || rt.memory_limits.run;
|
run_timeout = run_timeout || rt.timeouts.run;
|
||||||
resolve(
|
resolve(
|
||||||
new Job({
|
new Job({
|
||||||
runtime: rt,
|
runtime: rt,
|
||||||
|
|
|
@ -215,7 +215,7 @@ options.forEach(option => {
|
||||||
|
|
||||||
const parsed_val = parser(env_val);
|
const parsed_val = parser(env_val);
|
||||||
|
|
||||||
const value = env_val === undefined ? option.default : parsed_val;
|
const value = parsed_val || option.default;
|
||||||
|
|
||||||
option.validators.for_each(validator => {
|
option.validators.for_each(validator => {
|
||||||
let response = null;
|
let response = null;
|
||||||
|
|
|
@ -27,7 +27,7 @@ setInterval(() => {
|
||||||
}, 10);
|
}, 10);
|
||||||
|
|
||||||
class Job {
|
class Job {
|
||||||
constructor({ runtime, files, args, stdin, timeouts, memory_limits }) {
|
constructor({ runtime, files, args, stdin }) {
|
||||||
this.uuid = uuidv4();
|
this.uuid = uuidv4();
|
||||||
this.runtime = runtime;
|
this.runtime = runtime;
|
||||||
this.files = files.map((file, i) => ({
|
this.files = files.map((file, i) => ({
|
||||||
|
@ -38,9 +38,6 @@ class Job {
|
||||||
this.args = args;
|
this.args = args;
|
||||||
this.stdin = stdin;
|
this.stdin = stdin;
|
||||||
|
|
||||||
this.timeouts = timeouts;
|
|
||||||
this.memory_limits = memory_limits;
|
|
||||||
|
|
||||||
this.uid = config.runner_uid_min + uid;
|
this.uid = config.runner_uid_min + uid;
|
||||||
this.gid = config.runner_gid_min + gid;
|
this.gid = config.runner_gid_min + gid;
|
||||||
|
|
||||||
|
@ -223,8 +220,8 @@ class Job {
|
||||||
compile = await this.safe_call(
|
compile = await this.safe_call(
|
||||||
path.join(this.runtime.pkgdir, 'compile'),
|
path.join(this.runtime.pkgdir, 'compile'),
|
||||||
this.files.map(x => x.name),
|
this.files.map(x => x.name),
|
||||||
this.timeouts.compile,
|
this.runtime.timeouts.compile,
|
||||||
this.memory_limits.compile
|
this.runtime.memory_limits.compile
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -233,8 +230,8 @@ class Job {
|
||||||
const run = await this.safe_call(
|
const run = await this.safe_call(
|
||||||
path.join(this.runtime.pkgdir, 'run'),
|
path.join(this.runtime.pkgdir, 'run'),
|
||||||
[this.files[0].name, ...this.args],
|
[this.files[0].name, ...this.args],
|
||||||
this.timeouts.run,
|
this.runtime.timeouts.run,
|
||||||
this.memory_limits.run
|
this.runtime.memory_limits.run
|
||||||
);
|
);
|
||||||
|
|
||||||
this.state = job_states.EXECUTED;
|
this.state = job_states.EXECUTED;
|
||||||
|
@ -266,8 +263,8 @@ class Job {
|
||||||
const { error, code, signal } = await this.safe_call(
|
const { error, code, signal } = await this.safe_call(
|
||||||
path.join(this.runtime.pkgdir, 'compile'),
|
path.join(this.runtime.pkgdir, 'compile'),
|
||||||
this.files.map(x => x.name),
|
this.files.map(x => x.name),
|
||||||
this.timeouts.compile,
|
this.runtime.timeouts.compile,
|
||||||
this.memory_limits.compile,
|
this.runtime.memory_limits.compile,
|
||||||
eventBus
|
eventBus
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -279,8 +276,8 @@ class Job {
|
||||||
const { error, code, signal } = await this.safe_call(
|
const { error, code, signal } = await this.safe_call(
|
||||||
path.join(this.runtime.pkgdir, 'run'),
|
path.join(this.runtime.pkgdir, 'run'),
|
||||||
[this.files[0].name, ...this.args],
|
[this.files[0].name, ...this.args],
|
||||||
this.timeouts.run,
|
this.runtime.timeouts.run,
|
||||||
this.memory_limits.run,
|
this.runtime.memory_limits.run,
|
||||||
eventBus
|
eventBus
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
{
|
{
|
||||||
"language": "zig",
|
"language": "zig",
|
||||||
"version": "0.8.0",
|
"version": "0.8.0",
|
||||||
"aliases": ["zig"],
|
"aliases": ["zig"]
|
||||||
"limit_overrides": {
|
|
||||||
"compile_timeout": 15000
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
29
piston
29
piston
|
@ -1,10 +1,7 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
cd "$(dirname "$0")"
|
||||||
|
|
||||||
EXECUTION_PATH="$PWD"
|
PISTON_ENV=$(cat .piston_env || echo dev)
|
||||||
PISTON_PATH="$(dirname "$(realpath "$0")")"
|
|
||||||
|
|
||||||
cd "$PISTON_PATH"
|
|
||||||
PISTON_ENV=$(cat .piston_env 2> /dev/null || echo dev)
|
|
||||||
|
|
||||||
docker_compose(){
|
docker_compose(){
|
||||||
if [ -f "docker-compose.$PISTON_ENV.yaml" ]; then
|
if [ -f "docker-compose.$PISTON_ENV.yaml" ]; then
|
||||||
|
@ -35,12 +32,11 @@ case $1 in
|
||||||
echo
|
echo
|
||||||
echo "Development Commands:"
|
echo "Development Commands:"
|
||||||
|
|
||||||
if [ "$PISTON_ENV" == dev ]; then
|
if [ $PISTON_ENV == dev ]; then
|
||||||
|
|
||||||
echo " clean-pkgs Clean any package build artifacts on disk"
|
echo " clean-pkgs Clean any package build artifacts on disk"
|
||||||
echo " clean-repo Remove all packages from local repo"
|
echo " clean-repo Remove all packages from local repo"
|
||||||
echo " list-pkgs Lists all packages that can be built"
|
echo " build-pkg <package> <version> Build a package"
|
||||||
echo " build-pkg <package> <version> [builder] Build a package [with desired builder image]"
|
|
||||||
echo " rebuild Build and restart the docker container"
|
echo " rebuild Build and restart the docker container"
|
||||||
echo " lint Lint the codebase using prettier"
|
echo " lint Lint the codebase using prettier"
|
||||||
|
|
||||||
|
@ -60,7 +56,7 @@ case $1 in
|
||||||
restart) docker_compose restart ;;
|
restart) docker_compose restart ;;
|
||||||
start)
|
start)
|
||||||
rm -f .git/hooks/pre-commit
|
rm -f .git/hooks/pre-commit
|
||||||
ln -s "$PISTON_PATH/pre-commit" "$PISTON_PATH/.git/hooks/pre-commit"
|
ln -s $(realpath $(dirname "$0"))/pre-commit .git/hooks/pre-commit
|
||||||
docker_compose up -d
|
docker_compose up -d
|
||||||
;;
|
;;
|
||||||
stop) docker_compose down ;;
|
stop) docker_compose down ;;
|
||||||
|
@ -70,7 +66,6 @@ case $1 in
|
||||||
|
|
||||||
update)
|
update)
|
||||||
git pull
|
git pull
|
||||||
cd cli && npm i > /dev/null && cd -
|
|
||||||
docker_compose pull
|
docker_compose pull
|
||||||
docker_compose up -d
|
docker_compose up -d
|
||||||
;;
|
;;
|
||||||
|
@ -78,15 +73,12 @@ case $1 in
|
||||||
clean-pkgs) git clean -fqXd packages ;;
|
clean-pkgs) git clean -fqXd packages ;;
|
||||||
clean-repo) git clean -fqXd repo ;;
|
clean-repo) git clean -fqXd repo ;;
|
||||||
|
|
||||||
list-pkgs) find packages -depth 2 | awk -F/ '$2 && $3{ print $2 "-" $3 }' | column ;;
|
|
||||||
|
|
||||||
build-pkg)
|
build-pkg)
|
||||||
PKGSLUG="$2-$3"
|
PKGSLUG="$2-$3"
|
||||||
BUILDER="${4:-piston-repo-builder}"
|
|
||||||
echo "Building $PKGSLUG"
|
echo "Building $PKGSLUG"
|
||||||
echo "Ensuring latest builder image"
|
echo "Ensuring latest builder image"
|
||||||
docker build repo -t "$BUILDER"
|
docker build repo -t piston-repo-builder
|
||||||
docker run --rm -v "$PWD:/piston" "$BUILDER" --no-server "$PKGSLUG"
|
docker run --rm -v "$(realpath $(dirname "$0")):/piston" piston-repo-builder --no-server $PKGSLUG
|
||||||
;;
|
;;
|
||||||
|
|
||||||
lint)
|
lint)
|
||||||
|
@ -94,8 +86,9 @@ case $1 in
|
||||||
npx prettier --ignore-unknown --write .
|
npx prettier --ignore-unknown --write .
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
[ -d ./cli/node_modules ] || npm i > /dev/null
|
cd cli
|
||||||
cd "$EXECUTION_PATH"
|
npm i > /dev/null
|
||||||
node "${PISTON_PATH}/cli/index.js" "$@"
|
cd ../
|
||||||
|
node cli/index.js "$@"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
Loading…
Reference in New Issue