Description:
add task queue access control, grader status git-svn-id: http://theory.cpe.ku.ac.th/grader/cli/trunk/scripts@58 6386c4cd-e34a-4fa8-8920-d93eb39b512e
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r20:4c69afce24c0 - - 3 files changed: 31 inserted, 6 deleted

@@ -5,6 +5,9
5 5
6 6 TALKATIVE = true
7 7
8 + REPORT_GRADER = true
9 + GRADER_IP_ADDRESS = '158.108.111.111'
10 +
8 11 def report_comment(comment)
9 12 if comment.chomp =~ /^P+$/ # all P's
10 13 'passed'
@@ -5,6 +5,9
5 5
6 6 TALKATIVE = true
7 7
8 + REPORT_GRADER = true
9 + GRADER_IP_ADDRESS = '158.108.111.111'
10 +
8 11 def report_comment(comment)
9 12 comment.chomp
10 13 end
@@ -111,7 +111,7
111 111 user_dir = "#{USER_RESULT_DIR}/#{user.login}"
112 112 Dir.mkdir(user_dir) if !FileTest.exist?(user_dir)
113 113
114 - problem_out_dir = "#{user_dir}/#{problem.name}"
114 + problem_out_dir = "#{user_dir}/#{problem.name}/#{submission_id}"
115 115 Dir.mkdir(problem_out_dir) if !FileTest.exist?(problem_out_dir)
116 116
117 117 problem_home = "#{PROBLEMS_DIR}/#{problem.name}"
@@ -171,32 +171,50
171 171 puts "environment: #{GRADER_ENV}"
172 172 require File.dirname(__FILE__) + "/environment.rb"
173 173
174 - #main program
174 + #reading rails environment
175 175 talk 'Reading rails environment'
176 176
177 177 RAILS_ENV = 'development'
178 178 require RAILS_APP_DIR + '/config/environment'
179 179
180 + #register grader process
181 + if REPORT_GRADER
182 + grader_proc = GraderProcess.register(GRADER_IP_ADDRESS,
183 + Process.pid,
184 + grader_mode)
185 + else
186 + grader_proc = nil
187 + end
188 +
180 189 case grader_mode
181 190 when "queue"
182 191 talk 'Grader queue'
183 192 while true
193 +
184 194 if check_stopfile # created by calling grader stop
185 195 clear_stopfile
186 196 puts "stopped"
197 + grader_proc.report_inactive if grader_proc!=nil
187 198 exit(0)
188 199 end
189 200
190 - task = Task.find(:first, :order => 'created_at')
201 + task = Task.get_inqueue_and_change_status(Task::STATUS_GRADING)
191 202 if task!=nil
203 + grader_proc.report_active(task) if grader_proc!=nil
204 +
192 205 grade(task.submission_id)
193 - task.destroy
206 + task.status_complete
194 207 else
195 - sleep(1)
208 + #grader_proc.report_active if grader_proc!=nil
209 +
210 + sleep(5)
196 211 end
197 212 end
198 213
199 214 when "prob"
215 +
216 + grader_proc.report_active if grader_proc!=nil
217 +
200 218 prob = Problem.find_by_name(ARGV[2])
201 219 if prob==nil
202 220 puts "cannot find problem: #{ARGV[2]}"
@@ -215,7 +233,8
215 233 end
216 234 end
217 235
218 -
236 + # report inactive
237 + grader_proc.report_inactive if grader_proc!=nil
219 238
220 239
221 240
You need to be logged in to leave comments. Login now