Description:
add more logging
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r174:09d1e857c1e3 - - 3 files changed: 17 inserted, 3 deleted

@@ -57,11 +57,14
57 the problem name must be specified by the next argument.
57 the problem name must be specified by the next argument.
58
58
59 additional options:
59 additional options:
60 + --all-sub re-grade every submissions instead of just the latest submission of each user.
60
61
61 - --all-sub re-grade every submissions instead of just the latest submission of each user.
62 sub: re-grader the specified submission.
62 sub: re-grader the specified submission.
63 The submission ID to be re-graded must be specified by the next argument.
63 The submission ID to be re-graded must be specified by the next argument.
64
64
65 + options:
66 + --err-log log error to a file in the log dir
67 +
65 (3) create stop-file to stop running grader in queue mode
68 (3) create stop-file to stop running grader in queue mode
66 (4) You are here.
69 (4) You are here.
67 USAGE
70 USAGE
@@ -134,6 +137,8
134
137
135 options[:all_sub] = (ARGV.delete('--all-sub') != nil)
138 options[:all_sub] = (ARGV.delete('--all-sub') != nil)
136
139
140 + options[:err_log] = (ARGV.delete('--err-log') != nil)
141 +
137 return options
142 return options
138 end
143 end
139
144
@@ -420,6 +425,13
420
425
421 #set loggin environment
426 #set loggin environment
422 ENV['GRADER_LOGGING'] = log_file_name
427 ENV['GRADER_LOGGING'] = log_file_name
428 + if options[:err_log]
429 + err_file_name = log_file_name + '.err'
430 + $stderr.reopen(err_file_name,"a")
431 + log "STDERR log to file [#{err_file_name}]"
432 + warn "start logging for grader PID #{Process.id} on #{Time.now.in_time_zone}"
433 + end
434 +
423
435
424 # register exit handler to report inactive, and terminated
436 # register exit handler to report inactive, and terminated
425 at_exit do
437 at_exit do
@@ -118,8 +118,10
118
118
119 talk grading_dir
119 talk grading_dir
120 Dir.chdir grading_dir
120 Dir.chdir grading_dir
121 - cmd = "#{problem_home}/script/judge #{language} #{fname}"
121 + script_name = "#{problem_home}/script/judge"
122 + cmd = "#{script_name} #{language} #{fname}"
122 talk "CMD: #{cmd}"
123 talk "CMD: #{cmd}"
124 + warn "ERROR: file does not exists #{script_name}" unless File.exists? script_name
123 system(cmd)
125 system(cmd)
124 end
126 end
125
127
@@ -45,7 +45,7
45 end
45 end
46
46
47 def grade_submission(submission)
47 def grade_submission(submission)
48 - puts "Submission: #{submission.id} by #{submission.user.full_name}"
48 + puts "Submission: #{submission.id} by #{submission.try(:user).try(:full_name)}"
49 @engine.grade(submission)
49 @engine.grade(submission)
50 end
50 end
51
51
You need to be logged in to leave comments. Login now