better error handling

This commit is contained in:
Sebastian Serth
2020-05-12 18:52:08 +02:00
parent 75b0767677
commit 2b7170b202
2 changed files with 2 additions and 2 deletions

View File

@ -57,7 +57,7 @@ module SubmissionScoring
score += output[:score] * output[:weight]
end
if output[:status] == :timeout
if output.present? && output[:status] == :timeout
output[:stderr] += "\n\n#{t('exercises.editor.timeout', permitted_execution_time: submission.exercise.execution_environment.permitted_execution_time.to_s)}"
end
end

View File

@ -453,7 +453,7 @@ class DockerClient
Timeout.timeout(@execution_environment.permitted_execution_time.to_i) do
# TODO: check phusion doku again if we need -i -t options here
# https://stackoverflow.com/questions/363223/how-do-i-get-both-stdout-and-stderr-to-go-to-the-terminal-and-a-log-file
output = container.exec(['bash', '-c', "#{command} 1> >(tee -a /tmp/stdout.log) 2> >(tee -a /tmp/stderr.log >&2); rm /tmp/std*.log"], tty: false)
output = container.exec(['bash', '-c', "#{command} 1> >(tee -a /tmp/stdout.log) 2> >(tee -a /tmp/stderr.log >&2); rm -f /tmp/std*.log"], tty: false)
end
Rails.logger.debug 'output from container.exec'
Rails.logger.debug output