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