Skip to content

Commit 208a1b1

Browse files
Merge branch 'master' into nim
2 parents 9b81f25 + ef16006 commit 208a1b1

29 files changed

+448
-259
lines changed

.dockerignore

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
.*
2-
log/*
3-
tmp/*
42
Dockerfile*
3+
LICENSE
4+
README.md
55
docker-compose*
6+
judge0-api.conf*
7+
log/*
68
scripts
9+
!scripts/load-config
710
!scripts/prod-gen-api-docs
811
!scripts/run-server
9-
!scripts/run-worker
10-
README.md
11-
LICENSE
12-
judge0-api.conf*
12+
!scripts/run-workers
13+
srv
14+
tmp/*

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/.bundle
22
/log/*
33
/tmp/*
4+
srv
45
!/log/.keep
56
!/tmp/.keep
67
.byebug_history

Dockerfile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM judge0/api-base:nim0.20.0
1+
FROM judge0/api-base:nim-latest
22

33
RUN curl -fSsL "https://deb.nodesource.com/setup_12.x" | bash - && \
44
apt-get update && \
@@ -19,15 +19,15 @@ RUN echo "gem: --no-document" > /root/.gemrc && \
1919

2020
EXPOSE 3000
2121

22-
WORKDIR /usr/src/api
23-
COPY Gemfile* /usr/src/api/
22+
WORKDIR /api
23+
COPY Gemfile* ./
2424
RUN RAILS_ENV=production bundle
2525

26-
COPY . /usr/src/api
26+
COPY . .
2727
RUN RAILS_ENV=production bundle && \
2828
./scripts/prod-gen-api-docs
2929

3030
CMD ["./scripts/run-server"]
3131

3232
LABEL maintainer="Herman Zvonimir Došilović, hermanz.dosilovic@gmail.com"
33-
LABEL version="1.2.0-nim0.20.0"
33+
LABEL version="1.4.0-nim-latest"

Dockerfile.dev

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
FROM judge0/api
2-
LABEL maintainer="Herman Zvonimir Došilović, hermanz.dosilovic@gmail.com"
32

4-
RUN apt-get update && apt-get install -y vim
3+
ARG DEV_USER=judge0
4+
ARG DEV_USER_ID=1000
55

6-
ENV TERM xterm
7-
CMD sleep infinity
6+
RUN apt-get update && \
7+
apt-get install -y --no-install-recommends vim && \
8+
useradd -u $DEV_USER_ID -m -r $DEV_USER && \
9+
echo "$DEV_USER ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers
810

9-
ARG DEV_USER
10-
ARG DEV_USER_ID
11+
USER $DEV_USER
1112

12-
RUN useradd -u $DEV_USER_ID -m -r $DEV_USER && \
13-
echo "$DEV_USER ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers && \
14-
echo "set -a" >> /home/$DEV_USER/.bashrc && \
15-
echo "source /usr/src/api/judge0-api.conf" >> /home/$DEV_USER/.bashrc
13+
CMD ["sleep", "infinity"]
1614

17-
USER $DEV_USER
15+
LABEL maintainer="Herman Zvonimir Došilović, hermanz.dosilovic@gmail.com"

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,11 @@ You need to run Rails API and Worker in order to have Judge0 API fully operation
9494
9595
1. Open new development shell and in there run Rails API server:
9696
```
97-
$ ./scripts/dev-run-server
97+
$ ./scripts/run-server
9898
```
9999
2. Open new development shell again and in there run Worker process:
100100
```
101-
$ ./scripts/dev-run-worker
101+
$ ./scripts/run-workers
102102
```
103103
3. Open http://localhost:3000 in your browser.
104104

app/controllers/sessions_controller.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@ def authorize_request
2222
end
2323

2424
def safe_compare(token, header)
25+
token = token.to_s
26+
header = header.to_s
2527
return false unless token.present?
2628
provided_token = (request.headers[header] || params[header]).to_s
2729
token.split.each do |value|
2830
return false if ActiveSupport::SecurityUtils.secure_compare(value, provided_token)
2931
end
3032
true
3133
end
32-
end
34+
end

app/controllers/submissions_controller.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ def create
3838
return
3939
end
4040

41+
if Resque.size("default") >= Config::MAX_QUEUE_SIZE
42+
render json: { error: "queue is full" }, status: :service_unavailable
43+
return
44+
end
45+
4146
submission = Submission.new(submission_params)
4247

4348
if submission.save
@@ -60,6 +65,8 @@ def submission_params
6065
submission_params = params.permit(
6166
:source_code,
6267
:language_id,
68+
:compiler_options,
69+
:command_line_arguments,
6370
:number_of_runs,
6471
:stdin,
6572
:expected_output,

app/enumerations/status.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ class Status < Enumerations::Base
1111
sigabrt: { id: 10, name: 'Runtime Error (SIGABRT)' },
1212
nzec: { id: 11, name: 'Runtime Error (NZEC)' },
1313
other: { id: 12, name: 'Runtime Error (Other)' },
14-
boxerr: { id: 13, name: 'Internal Error' }
14+
boxerr: { id: 13, name: 'Internal Error' },
15+
exeerr: { id: 14, name: 'Exec Format Error' }
1516

1617
def self.find_runtime_error_by_status_code(status_code)
1718
case status_code.to_i

app/helpers/config.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ module Config
33
# https://github.com/judge0/api/blob/master/judge0-api.conf.default
44

55
ENABLE_WAIT_RESULT = ENV['ENABLE_WAIT_RESULT'] != "false"
6+
ENABLE_COMPILER_OPTIONS = ENV["ENABLE_COMPILER_OPTIONS"] != "false"
7+
ALLOWED_LANGUAGES_FOR_COMPILER_OPTIONS = ENV["ALLOWED_LANGUAGES_FOR_COMPILER_OPTIONS"].to_s.strip.split
8+
ENABLE_COMMAND_LINE_ARGUMENTS = ENV["ENABLE_COMMAND_LINE_ARGUMENTS"] != "false"
9+
MAX_QUEUE_SIZE = (ENV['MAX_QUEUE_SIZE'].presence || 100).to_i
610
CPU_TIME_LIMIT = (ENV['CPU_TIME_LIMIT'].presence || 2).to_f
711
MAX_CPU_TIME_LIMIT = (ENV['MAX_CPU_TIME_LIMIT'].presence || 15).to_f
812
CPU_EXTRA_TIME = (ENV['CPU_EXTRA_TIME'].presence || 0.5).to_f
@@ -27,6 +31,10 @@ module Config
2731
def self.config_info
2832
@@default_confg ||= {
2933
"enable_wait_result": ENABLE_WAIT_RESULT,
34+
"enable_compiler_options": ENABLE_COMPILER_OPTIONS,
35+
"allowed_languages_for_compile_options": ALLOWED_LANGUAGES_FOR_COMPILER_OPTIONS,
36+
"enable_command_line_arguments": ENABLE_COMMAND_LINE_ARGUMENTS,
37+
"max_queue_size": MAX_QUEUE_SIZE,
3038
"cpu_time_limit": CPU_TIME_LIMIT,
3139
"max_cpu_time_limit": MAX_CPU_TIME_LIMIT,
3240
"cpu_extra_time": CPU_EXTRA_TIME,

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy