Changeset 580
- Timestamp:
- 03/28/07 13:44:08 (2 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/taskers/hefeweizen_tasker_application_http_server.rb
r569 r580 39 39 require 'logger' 40 40 require 'pp' 41 require 'monitor' 41 42 42 43 $exit = false 43 44 44 Signal.trap("INT") do $stderr.puts "#{$0}: HefeWeizen Tasker HTTP Server caught INT signal. not exitting"; end 45 Signal.trap("USR1") do $stderr.puts "#{$0}: HefeWeizen Tasker HTTP Server caught USR1 signal. Exitting ... "; $exit = true; end 45 $instance = 0 46 $pipes = [] 47 $pipes.extend MonitorMixin 48 49 $mutex = Mutex.new 50 51 52 Signal.trap("INT") do $stdout.puts "#{$0}: HefeWeizen Tasker HTTP Server caught INT signal. not exitting"; end 53 Signal.trap("USR1") { 54 $stdout.puts "#{$0}: HefeWeizen Tasker HTTP Server caught USR1 signal. Exitting ... " 55 # TODO check where process is. Eg clean up pipe to HTTP Server. 56 57 $mutex.synchronize do 58 if $instance > 0 then 59 $pipes.synchronize do 60 $stdout.puts "HTTP Server Tasker needs to cleanup files." 61 $pipes.each{ | pipe | 62 begin 63 FileUtils.rm_rf(pipe) 64 rescue Exception => e 65 $stdout.puts "Exception: #{e.to_s}" 66 end 67 } 68 end 69 end 70 $stdout.puts "HTTP Server Taserk Exitting." 71 Process.exit! 0 72 end 73 } 46 74 47 75 module HefeWeizen … … 70 98 71 99 def do_POST(req, resp) 72 100 101 $mutex.synchronize do 102 $instance += 1 103 end 73 104 # 0. if we are in the testing environment 74 105 if @config['BIG_ANIA_LOAD_TEST_ENVIRONMENT'] == 'true' then … … 86 117 # resp.body = "blah blah blah" 87 118 # resp.status = 204 88 return 119 return finished 89 120 end 90 121 end … … 130 161 131 162 my_pipe = "#{@config['PIPE_DIR']}/pipe_to_http_server_#{now.to_f.to_s}" 163 $pipes.synchronize do 164 $pipes.push my_pipe 165 end 132 166 command = "mkfifo #{my_pipe}" 133 167 system(command) … … 244 278 pipe_to_me.close 245 279 FileUtils.rm(my_pipe) 246 247 return true 248 end 280 $pipes.synchronize do 281 $pipes.delete my_pipe 282 end 283 return finished 284 end 285 286 private 287 def finished 288 $mutex.synchronize do 289 $instance -= 1 290 end 291 end 292 249 293 end 250 294
