Skip to content

Commit

Permalink
Add support for redirecting stderr to stdout.
Browse files Browse the repository at this point in the history
  • Loading branch information
hermanzdosilovic committed Jan 13, 2020
1 parent 4116b9c commit 8e6617a
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 3 deletions.
3 changes: 2 additions & 1 deletion app/controllers/submissions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ def submission_params
:max_processes_and_or_threads,
:enable_per_process_and_thread_time_limit,
:enable_per_process_and_thread_memory_limit,
:max_file_size
:max_file_size,
:redirect_stderr_to_stdout
)

params[:base64_encoded] == "true" ? decode_params(submission_params) : submission_params
Expand Down
4 changes: 3 additions & 1 deletion app/helpers/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ module Config
MAX_MAX_FILE_SIZE = (ENV['MAX_MAX_FILE_SIZE'].presence || 4096).to_i
NUMBER_OF_RUNS = (ENV['NUMBER_OF_RUNS'].presence || 1).to_i
MAX_NUMBER_OF_RUNS = (ENV['MAX_NUMBER_OF_RUNS'].presence || 20).to_i
REDIRECT_STDERR_TO_STDOUT = ENV['REDIRECT_STDERR_TO_STDOUT'] == "true"

def self.config_info
@@default_confg ||= {
Expand Down Expand Up @@ -56,7 +57,8 @@ def self.config_info
"max_file_size": MAX_FILE_SIZE,
"max_max_file_size": MAX_MAX_FILE_SIZE,
"number_of_runs": NUMBER_OF_RUNS,
"max_number_of_runs": MAX_NUMBER_OF_RUNS
"max_number_of_runs": MAX_NUMBER_OF_RUNS,
"redirect_stderr_to_stdout": REDIRECT_STDERR_TO_STDOUT
}
end
end
1 change: 1 addition & 0 deletions app/jobs/isolate_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ def run
-s \
-b #{box_id} \
-M #{metadata_file} \
#{submission.redirect_stderr_to_stdout ? "--stderr-to-stdout" : ""} \
-t #{submission.cpu_time_limit} \
-x #{submission.cpu_extra_time} \
-w #{submission.wall_time_limit} \
Expand Down
4 changes: 4 additions & 0 deletions app/models/submission.rb
Original file line number Diff line number Diff line change
Expand Up @@ -210,5 +210,9 @@ def set_defaults
Config::ENABLE_PER_PROCESS_AND_THREAD_MEMORY_LIMIT
)
self.max_file_size ||= Config::MAX_FILE_SIZE
self.redirect_stderr_to_stdout = NilValue.value_or_default(
self.redirect_stderr_to_stdout,
Config::REDIRECT_STDERR_TO_STDOUT
)
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddRedirectStderrToStdoutToSubmission < ActiveRecord::Migration[5.0]
def change
add_column :submissions, :redirect_stderr_to_stdout, :boolean
end
end
3 changes: 2 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20191230001624) do
ActiveRecord::Schema.define(version: 20200113231131) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Expand Down Expand Up @@ -53,6 +53,7 @@
t.decimal "wall_time"
t.string "compiler_options"
t.string "command_line_arguments"
t.boolean "redirect_stderr_to_stdout"
t.index ["token"], name: "index_submissions_on_token", using: :btree
end

Expand Down
4 changes: 4 additions & 0 deletions judge0-api.conf.default
Original file line number Diff line number Diff line change
Expand Up @@ -232,3 +232,7 @@ NUMBER_OF_RUNS=
# Maximum custom NUMBER_OF_RUNS.
# Default: 20
MAX_NUMBER_OF_RUNS=

# Redirect stderr to stdout.
# Default: false
REDIRECT_STDERR_TO_STDOUT=

0 comments on commit 8e6617a

Please sign in to comment.