hayabusa 0.0.28 → 0.0.29

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +4 -4
  3. data/Rakefile +0 -14
  4. data/bin/hayabusa_fcgi.fcgi +1 -0
  5. data/lib/hayabusa.rb +119 -117
  6. data/lib/hayabusa_database.rb +84 -84
  7. data/lib/hayabusa_datarow.rb +873 -0
  8. data/lib/hayabusa_objects.rb +1455 -0
  9. data/lib/hayabusa_revision.rb +347 -0
  10. data/lib/models/log.rb +27 -27
  11. data/lib/models/log_access.rb +20 -20
  12. data/lib/models/log_data.rb +6 -6
  13. data/lib/models/log_data_link.rb +2 -2
  14. data/lib/models/log_data_value.rb +5 -5
  15. data/lib/models/log_link.rb +12 -12
  16. data/lib/models/session.rb +6 -6
  17. metadata +75 -57
  18. data/.document +0 -5
  19. data/.rspec +0 -1
  20. data/Gemfile +0 -25
  21. data/Gemfile.lock +0 -105
  22. data/VERSION +0 -1
  23. data/bin/hayabusa_fcgi.fcgi +0 -42
  24. data/conf/apache2_cgi_rhtml_conf.conf +0 -10
  25. data/conf/apache2_fcgi_rhtml_conf.conf +0 -22
  26. data/conf/apache2_hayabusa_conf.conf +0 -15
  27. data/hayabusa.gemspec +0 -171
  28. data/pages/benchmark.rhtml +0 -0
  29. data/pages/benchmark_print.rhtml +0 -14
  30. data/pages/benchmark_simple.rhtml +0 -3
  31. data/pages/benchmark_threadded_content.rhtml +0 -21
  32. data/pages/config_cgi.rb +0 -22
  33. data/pages/config_fcgi.rb +0 -22
  34. data/pages/debug_database_connections.rhtml +0 -46
  35. data/pages/debug_http_sessions.rhtml +0 -40
  36. data/pages/debug_memory_usage.rhtml +0 -39
  37. data/pages/error_notfound.rhtml +0 -12
  38. data/pages/image.png +0 -0
  39. data/pages/logs_latest.rhtml +0 -57
  40. data/pages/logs_show.rhtml +0 -32
  41. data/pages/spec.rhtml +0 -41
  42. data/pages/spec_exit.rhtml +0 -5
  43. data/pages/spec_multiple_threads.rhtml +0 -18
  44. data/pages/spec_sleeper.rhtml +0 -4
  45. data/pages/spec_test_multiple_clients.rhtml +0 -3
  46. data/pages/spec_thread_joins.rhtml +0 -29
  47. data/pages/spec_threadded_content.rhtml +0 -40
  48. data/pages/spec_vars_get.rhtml +0 -4
  49. data/pages/spec_vars_header.rhtml +0 -3
  50. data/pages/spec_vars_post.rhtml +0 -4
  51. data/pages/spec_vars_post_fileupload.rhtml +0 -19
  52. data/pages/testpic.jpeg +0 -0
  53. data/pages/tests.rhtml +0 -14
  54. data/pages/threadded_content_test.rhtml +0 -23
  55. data/spec/fcgi_multiple_processes_spec.rb +0 -104
  56. data/spec/hayabusa_spec.rb +0 -423
  57. data/spec/spec_helper.rb +0 -12
  58. data/spec/test_upload.xlsx +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: bd7ec4c88a34a72469fb9c68fa761f3c19d29167
4
- data.tar.gz: 6a995b84d0c480348b0075fc175484d94f4ebbac
2
+ SHA256:
3
+ metadata.gz: 60e88035481dc2afdc4ee23c24f2c44a1b504890c62b1e228b2e813f9d3b15a7
4
+ data.tar.gz: ff6b3e9c203f94ce49c7e1cc431b3c89a09410ee8a0f2c45a7eb2ac41964fe4c
5
5
  SHA512:
6
- metadata.gz: 6691e6935969b440bfa9dbe66b65e0c0bb908b45d69d1907ec3621ec834fd2b9d9631afb956539bcd1a8991f0a7e5c1cb258b5cc406b2c067801e842b34fca47
7
- data.tar.gz: 00a35f4552f381effb0329dcd857f49cfd19bc1a80662a5c3117fcc053bd5c3b170f6f23f916b3fe8d84049a77180d0b0e256c2eec7d048a86ed0dad2db33780
6
+ metadata.gz: e5205de4cf85d3a269e393d972a18e430afeb6c201e441ccd4e95589d5eeb2eac12e8b1cdeeed5f298657eb9aaf9314e13d0244a3aca5de0e8ac941e771513aa
7
+ data.tar.gz: 83addfb1405a664473579b8f9abbea6b7e4e3d4bc101bda50acc35a193298be340cd8a324964f8f2d4a59dff1a39148f1a81f9fb74b7c22e11fb837a06c39a73
data/README.md CHANGED
@@ -6,7 +6,7 @@ It uses ERubis to parse .rhtml files and caches the bytecode for Ruby-files.
6
6
 
7
7
 
8
8
  ## Contributing to hayabusa
9
-
9
+
10
10
  * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
11
11
  * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
12
12
  * Fork the project
@@ -40,7 +40,7 @@ require "sqlite3"
40
40
  appsrv = Hayabusa.new(
41
41
  port: 10080,
42
42
  doc_root: "#{File.dirname(__FILE__)}/doc_root",
43
- db: Knj::Db.new(
43
+ db: Baza::Db.new(
44
44
  type: "sqlite3",
45
45
  path: "#{File.dirname(__FILE__)}/test.sqlite3"
46
46
  )
@@ -114,12 +114,12 @@ You can also test if the headers are sent for your HTTP-session or not like this
114
114
  sleep 4
115
115
  print "Test 1<br />"
116
116
  end
117
-
117
+
118
118
  _hb.threadded_content do
119
119
  sleep 1
120
120
  print "Test 2<br />"
121
121
  end
122
-
122
+
123
123
  _hb.threadded_content do
124
124
  sleep 3
125
125
  print "Test 3<br />"
data/Rakefile CHANGED
@@ -11,20 +11,6 @@ rescue Bundler::BundlerError => e
11
11
  end
12
12
  require 'rake'
13
13
 
14
- require 'jeweler'
15
- Jeweler::Tasks.new do |gem|
16
- # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
- gem.name = "hayabusa"
18
- gem.homepage = "http://github.com/kaspernj/hayabusa"
19
- gem.license = "MIT"
20
- gem.summary = %Q{A threadded web/app-server that supports stand-alone, CGI and FCGI-modes.}
21
- gem.description = %Q{A threadded web/app-server that focuses on threadding, shared ressources, speed and more.}
22
- gem.email = "k@spernj.org"
23
- gem.authors = ["Kasper Johansen"]
24
- # dependencies defined in Gemfile
25
- end
26
- Jeweler::RubygemsDotOrgTasks.new
27
-
28
14
  require 'rspec/core'
29
15
  require 'rspec/core/rake_task'
30
16
  RSpec::Core::RakeTask.new(:spec) do |spec|
@@ -0,0 +1 @@
1
+ hayabusa_fcgi.rb
data/lib/hayabusa.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require "base64"
2
+ require "baza"
2
3
  require "digest"
3
4
  require "stringio"
4
5
  require "timeout"
@@ -14,19 +15,19 @@ require "timeout"
14
15
  # appsrv.join
15
16
  class Hayabusa
16
17
  @@path = File.dirname(__FILE__)
17
-
18
+
18
19
  attr_reader :cio, :config, :httpserv, :debug, :db, :db_handler, :ob, :translations, :paused, :should_restart, :events, :mod_event, :db_handler, :gettext, :sessions, :logs_access_pending, :threadpool, :vars, :magic_procs, :magic_vars, :types, :eruby_cache, :httpsessions_ids
19
20
  attr_accessor :served, :should_restart, :should_restart_done
20
-
21
+
21
22
  #Autoloader for subclasses.
22
23
  def self.const_missing(name)
23
24
  require "#{File.dirname(__FILE__)}/hayabusa_#{name.to_s.downcase}.rb"
24
25
  return Hayabusa.const_get(name)
25
26
  end
26
-
27
+
27
28
  def initialize(config)
28
29
  raise "No arguments given." if !config.is_a?(Hash)
29
-
30
+
30
31
  @config = {
31
32
  :host => "0.0.0.0",
32
33
  :timeout => 30,
@@ -37,12 +38,12 @@ class Hayabusa
37
38
  :cleaner_timeout => 60,
38
39
  :mailing_time => 30
39
40
  }.merge(config)
40
-
41
+
41
42
  @config[:smtp_args] = {"smtp_host" => "localhost", "smtp_port" => 25} if !@config[:smtp_args]
42
43
  @config[:timeout] = 30 if !@config.has_key?(:timeout)
43
44
  raise "No ':doc_root' was given in arguments." if !@config.has_key?(:doc_root)
44
-
45
-
45
+
46
+
46
47
  #Require gems.
47
48
  require "rubygems"
48
49
  gems = [
@@ -51,15 +52,15 @@ class Hayabusa
51
52
  [:Tsafe, "tsafe"],
52
53
  [:Tpool, "tpool"]
53
54
  ]
54
-
55
+
55
56
  gems.each do |gem_i|
56
57
  if Kernel.const_defined?(gem_i[0])
57
58
  puts "Gem already loaded: '#{gem_i[1]}'." if @debug
58
59
  next
59
60
  end
60
-
61
+
61
62
  fpath = "#{@@path}/../../#{gem_i[1]}/lib/#{gem_i[1]}.rb"
62
-
63
+
63
64
  if File.exists?(fpath)
64
65
  puts "Loading custom gem-path: '#{fpath}'." if @debug
65
66
  require fpath
@@ -68,8 +69,8 @@ class Hayabusa
68
69
  require gem_i[1]
69
70
  end
70
71
  end
71
-
72
-
72
+
73
+
73
74
  #Setup default handlers if none are given.
74
75
  if !@config.has_key?(:handlers)
75
76
  @erb_handler = Hayabusa::Erb_handler.new
@@ -83,41 +84,41 @@ class Hayabusa
83
84
  }
84
85
  ]
85
86
  end
86
-
87
+
87
88
  if @config[:handlers_extra]
88
89
  @config[:handlers] += @config[:handlers_extra]
89
90
  end
90
-
91
-
91
+
92
+
92
93
  #Add extra handlers if given.
93
94
  @config[:handlers] += @config[:handlers_extra] if @config[:handlers_extra]
94
-
95
-
95
+
96
+
96
97
  #Setup cache to make .rhtml-calls faster.
97
98
  @config[:handlers_cache] = {}
98
99
  @config[:handlers].each do |handler_info|
99
100
  next if !handler_info[:file_ext] or !handler_info[:callback]
100
101
  @config[:handlers_cache][handler_info[:file_ext]] = handler_info[:callback]
101
102
  end
102
-
103
-
103
+
104
+
104
105
  @debug = @config[:debug]
105
106
  if !@config.key?(:debug_log) or @config[:debug_log]
106
107
  @debug_log = true
107
108
  else
108
109
  @debug_log = false
109
110
  end
110
-
111
+
111
112
  if @config[:debug_print]
112
113
  @debug_print = true
113
114
  else
114
115
  @debug_print = false
115
116
  end
116
-
117
+
117
118
  if !@config.key?(:debug_print_err) or @config[:debug_print_err]
118
119
  @debug_print_err = true
119
120
  end
120
-
121
+
121
122
  @paused = 0
122
123
  @paused_mutex = Mutex.new
123
124
  @should_restart = false
@@ -127,26 +128,26 @@ class Hayabusa
127
128
  @sessions = {}
128
129
  @eruby_cache = {}
129
130
  @httpsessions_ids = {}
130
-
131
+
131
132
  if @debug_log
132
133
  @log_fp = File.open("/tmp/hayabusa_#{@config[:title]}.log", "w")
133
134
  @log_fp.sync = true
134
135
  end
135
-
136
+
136
137
  @path_hayabusa = File.dirname(__FILE__)
137
-
138
-
138
+
139
+
139
140
  #If auto-restarting is enabled - start the modified events-module.
140
141
  if @config[:autorestart]
141
142
  paths = [
142
143
  "#{@path_hayabusa}/class_customio.rb"
143
144
  ]
144
-
145
+
145
146
  self.log_puts "Auto restarting." if @debug
146
147
  @mod_event = Knj::Event_filemod.new(:wait => 2, :paths => paths, &self.method(:on_event_filemod))
147
148
  end
148
-
149
-
149
+
150
+
150
151
  #Set up default file-types and merge given filetypes into it.
151
152
  @types = {
152
153
  :ico => "image/x-icon",
@@ -162,9 +163,9 @@ class Hayabusa
162
163
  :js => "text/javascript"
163
164
  }
164
165
  @types.merge!(@config[:filetypes]) if @config.key?(:filetypes)
165
-
166
-
167
-
166
+
167
+
168
+
168
169
  #Load various required files in the hayabusa-framework.
169
170
  files = [
170
171
  "#{@path_hayabusa}/hayabusa_ext/errors.rb",
@@ -174,51 +175,52 @@ class Hayabusa
174
175
  "#{@path_hayabusa}/hayabusa_ext/translations.rb",
175
176
  "#{@path_hayabusa}/hayabusa_ext/web.rb"
176
177
  ]
177
-
178
+
178
179
  files.each do |file|
179
180
  self.log_puts "Loading: '#{file}'." if @debug
180
181
  self.loadfile(file)
181
182
  end
182
-
183
-
183
+
184
+
184
185
  self.log_puts "Setting up database." if @debug
185
- if @config[:db].is_a?(Knj::Db)
186
+ if @config[:db].is_a?(Baza::Db)
186
187
  @db = @config[:db]
187
188
  elsif @config[:db].is_a?(Hash)
188
- @db = Knj::Db.new(@config[:db])
189
+ @db = Baza::Db.new(@config[:db])
189
190
  elsif @config[:db_args]
190
- @db = Knj::Db.new(@config[:db_args])
191
+ @db = Baza::Db.new(@config[:db_args])
191
192
  else
192
193
  if @config[:title]
193
194
  db_title = @config[:title]
194
195
  else
195
196
  db_title = Time.now.to_f.to_s.hash
196
197
  end
197
-
198
+
198
199
  db_path = "#{Knj::Os.tmpdir}/hayabusa_fallback_db_#{db_title}.sqlite3"
199
200
  @config[:dbrev] = true
200
-
201
+
201
202
  require "sqlite3" if RUBY_ENGINE != "jruby"
202
- @db = Knj::Db.new(
203
+ @db = Baza::Db.new(
203
204
  :type => "sqlite3",
204
205
  :path => db_path,
205
206
  :return_keys => "symbols",
206
207
  :index_append_table_name => true
207
208
  )
208
209
  end
209
-
210
-
210
+
211
+
211
212
  if !@config.key?(:dbrev) or @config[:dbrev]
212
213
  self.log_puts "Updating database." if @debug
213
214
  dbrev_args = {"schema" => Hayabusa::Database::SCHEMA, "db" => @db}
214
215
  dbrev_args.merge!(@config[:dbrev_args]) if @config.key?(:dbrev_args)
215
- Knj::Db::Revision.new.init_db(dbrev_args)
216
+
217
+ Hayabusa::Revision.new.init_db(dbrev_args)
216
218
  dbrev_args = nil
217
219
  end
218
-
219
-
220
+
221
+
220
222
  self.log_puts "Spawning objects." if @debug
221
- @ob = Knj::Objects.new(
223
+ @ob = Hayabusa::Objects.new(
222
224
  :db => db,
223
225
  :class_path => @path_hayabusa,
224
226
  :module => Hayabusa::Models,
@@ -227,52 +229,52 @@ class Hayabusa
227
229
  :require => false
228
230
  )
229
231
  @ob.events.connect(:no_date, &self.method(:no_date))
230
-
231
-
232
+
233
+
232
234
  if @config[:httpsession_db_args]
233
- @db_handler = Knj::Db.new(@config[:httpsession_db_args])
235
+ @db_handler = Baza::Db.new(@config[:httpsession_db_args])
234
236
  else
235
237
  @db_handler = @db
236
238
  end
237
-
238
-
239
+
240
+
239
241
  if @config[:locales_root]
240
242
  @gettext = Knj::Gettext_threadded.new("dir" => config[:locales_root])
241
243
  end
242
-
244
+
243
245
  require "#{@path_hayabusa}/kernel_ext/gettext_methods" if @config[:locales_gettext_funcs]
244
-
246
+
245
247
  if @config[:magic_methods] or !@config.has_key?(:magic_methods)
246
248
  self.log_puts "Loading magic-methods." if @debug
247
249
  require "#{@path_hayabusa}/kernel_ext/magic_methods"
248
250
  end
249
-
251
+
250
252
  if @config[:customio] or !@config.has_key?(:customio)
251
253
  self.log_puts "Loading custom-io." if @debug
252
-
254
+
253
255
  if $stdout.class.name != "Hayabusa::Custom_io"
254
256
  @cio = Hayabusa::Custom_io.new
255
257
  $stdout = @cio
256
258
  end
257
259
  end
258
-
259
-
260
+
261
+
260
262
  #Save the PID to the run-file.
261
263
  self.log_puts "Setting run-file." if @debug
262
264
  tmpdir = "#{Knj::Os.tmpdir}/hayabusa"
263
265
  tmppath = "#{tmpdir}/run_#{@config[:title]}"
264
-
266
+
265
267
  if !File.exists?(tmpdir)
266
268
  Dir.mkdir(tmpdir)
267
269
  File.chmod(0777, tmpdir)
268
270
  end
269
-
271
+
270
272
  File.open(tmppath, "w") do |fp|
271
273
  fp.write(Process.pid)
272
274
  end
273
275
  File.chmod(0777, tmppath)
274
-
275
-
276
+
277
+
276
278
  #Set up various events for the appserver.
277
279
  if !@config.key?(:events) or @config[:events]
278
280
  self.log_puts "Loading events." if @debug
@@ -298,171 +300,171 @@ class Hayabusa
298
300
  :connections_max => 1
299
301
  )
300
302
  @events.add_event(:name => :http_session_destruct)
301
-
303
+
302
304
  #This event is used if the user himself wants stuff to be cleaned up when the appserver is cleaning up stuff.
303
305
  @events.add_event(:name => :on_clean)
304
306
  end
305
-
307
+
306
308
  #Set up the 'vars'-variable that can be used to set custom global variables for web-requests.
307
309
  @vars = Knj::Hash_methods.new
308
310
  @magic_vars = {}
309
311
  @magic_procs = {}
310
-
311
-
312
+
313
+
312
314
  #Initialize the various feature-modules.
313
315
  self.log_puts "Init sessions." if @debug
314
316
  self.initialize_sessions
315
-
317
+
316
318
  if !@config.key?(:threadding) or @config[:threadding]
317
319
  self.loadfile("#{@path_hayabusa}/hayabusa_ext/threadding.rb")
318
320
  self.loadfile("#{@path_hayabusa}/hayabusa_ext/threadding_timeout.rb")
319
321
  self.log_puts "Init threadding." if @debug
320
322
  self.initialize_threadding
321
323
  end
322
-
324
+
323
325
  self.log_puts "Init mailing." if @debug
324
326
  self.initialize_mailing
325
-
327
+
326
328
  self.log_puts "Init errors." if @debug
327
329
  self.initialize_errors
328
-
330
+
329
331
  self.log_puts "Init logging." if @debug
330
332
  self.initialize_logging
331
-
333
+
332
334
  if !@config.key?(:cleaner) or @config[:cleaner]
333
335
  self.loadfile("#{@path_hayabusa}/hayabusa_ext/cleaner.rb")
334
336
  self.log_puts "Init cleaner." if @debug
335
337
  self.initialize_cleaner
336
338
  end
337
-
339
+
338
340
  if !@config.key?(:cmdline) or @config[:cmdline]
339
341
  self.loadfile("#{@path_hayabusa}/hayabusa_ext/cmdline.rb")
340
342
  self.log_puts "Init cmdline." if @debug
341
343
  self.initialize_cmdline
342
344
  end
343
-
344
-
345
+
346
+
345
347
  #Clear memory, flush emails, flush sessions and more at exit.
346
348
  Kernel.at_exit(&self.method(:stop))
347
-
348
-
349
+
350
+
349
351
  self.log_puts "Appserver spawned." if @debug
350
352
  end
351
-
353
+
352
354
  #Outputs to stderr and logs it.
353
355
  def log_puts(str)
354
356
  if @debug_log
355
357
  @log_fp.sync = true
356
358
  @log_fp.puts str
357
359
  end
358
-
360
+
359
361
  if @debug_print
360
362
  STDOUT.sync = true
361
363
  STDOUT.puts str
362
364
  end
363
-
365
+
364
366
  if @debug_print_err
365
367
  STDERR.sync = true
366
368
  STDERR.puts str
367
369
  end
368
370
  end
369
-
371
+
370
372
  def no_date(event, classname)
371
373
  return "[no date]"
372
374
  end
373
-
375
+
374
376
  def on_event_filemod(event, path)
375
377
  self.log_puts "File changed - restart server: #{path}"
376
378
  @should_restart = true
377
379
  @mod_event.destroy if @mod_event
378
380
  end
379
-
381
+
380
382
  #If you want to use auto-restart, every file reloaded through loadfile will be watched for changes. When changed the server will do a restart to reflect that.
381
383
  def loadfile(fpath)
382
384
  if !@config[:autorestart]
383
385
  require fpath
384
386
  return nil
385
387
  end
386
-
388
+
387
389
  rpath = File.realpath(fpath)
388
390
  raise "No such filepath: #{fpath}" if !rpath or !File.exists?(rpath)
389
-
391
+
390
392
  return true if @mod_files[rpath]
391
-
393
+
392
394
  @mod_event.args[:paths] << rpath
393
395
  @mod_files = rpath
394
-
396
+
395
397
  require rpath
396
398
  return false
397
399
  end
398
-
400
+
399
401
  #Start a new CGI-request.
400
402
  def start_cgi_request
401
403
  @cgi_http_session = Hayabusa::Cgi_session.new(:hb => self)
402
404
  end
403
-
405
+
404
406
  #Starts the HTTP-server and threadpool.
405
407
  def start
406
408
  #Start the appserver.
407
409
  self.log_puts "Spawning appserver." if @debug
408
410
  @httpserv = Hayabusa::Http_server.new(self)
409
411
  @httpserv.start
410
-
411
-
412
+
413
+
412
414
  self.log_puts "Starting appserver." if @debug
413
415
  Thread.current[:hayabusa] = {:hb => self} if !Thread.current[:hayabusa]
414
-
416
+
415
417
  if @config[:autoload]
416
418
  self.log_puts "Autoloading #{@config[:autoload]}" if @debug
417
419
  require @config[:autoload]
418
420
  end
419
-
421
+
420
422
  self.log_puts "Appserver startet." if @debug
421
423
  end
422
-
424
+
423
425
  #Stops the entire app and releases join.
424
426
  def stop
425
427
  return nil if @stop_called
426
428
  @stop_called = true
427
-
429
+
428
430
  self.log_puts "Stopping appserver." if @debug
429
431
  @httpserv.stop if @httpserv and @httpserv.respond_to?(:stop)
430
-
432
+
431
433
  self.log_puts "Stopping threadpool." if @debug
432
434
  @threadpool.stop if @threadpool
433
-
435
+
434
436
  #This should be done first to be sure it finishes (else we have a serious bug).
435
437
  self.log_puts "Flush out loaded sessions." if @debug
436
-
438
+
437
439
  #Flush sessions and mails (only if the modules are loaded).
438
440
  self.flush_error_emails(:ignore_time => true) if self.respond_to?(:flush_error_emails)
439
441
  self.sessions_flush if self.respond_to?(:sessions_flush)
440
442
  self.mail_flush if self.respond_to?(:mail_flush)
441
-
443
+
442
444
  self.log_puts "Stopping done..." if @debug
443
445
  end
444
-
446
+
445
447
  #Stop running any more HTTP-requests - make them wait.
446
448
  def pause
447
449
  @paused += 1
448
450
  end
449
-
451
+
450
452
  #Unpause - start handeling HTTP-requests again.
451
453
  def unpause
452
454
  @paused -= 1
453
455
  end
454
-
456
+
455
457
  #Returns true if paued - otherwise false.
456
458
  def paused?
457
459
  return true if @paused > 0
458
460
  return false
459
461
  end
460
-
462
+
461
463
  #Will stop handeling any more HTTP-requests, run the proc given and return handeling HTTP-requests.
462
464
  def paused_exec
463
465
  raise "No block given." if !block_given?
464
466
  self.pause
465
-
467
+
466
468
  begin
467
469
  sleep 0.2 while @httpserv and @httpserv.working_count and @httpserv.working_count > 0
468
470
  @paused_mutex.synchronize do
@@ -474,22 +476,22 @@ class Hayabusa
474
476
  self.unpause
475
477
  end
476
478
  end
477
-
479
+
478
480
  #Returns true if a HTTP-request is working. Otherwise false.
479
481
  def working?
480
482
  return true if @httpserv and @httpserv.working_count > 0
481
483
  return false
482
484
  end
483
-
485
+
484
486
  def self.data
485
487
  raise "Could not register current thread." if !Thread.current[:hayabusa]
486
488
  return Thread.current[:hayabusa]
487
489
  end
488
-
490
+
489
491
  #Sleeps until the server is stopped.
490
492
  def join
491
493
  raise "No http-server or http-server not running." if !@httpserv or !@httpserv.thread_accept
492
-
494
+
493
495
  begin
494
496
  @httpserv.thread_accept.join
495
497
  @httpserv.thread_restart.join if @httpserv and @httpserv.thread_restart
@@ -497,23 +499,23 @@ class Hayabusa
497
499
  self.log_puts "Trying to stop because of interrupt - please wait while various data is beging flushed." if @debug
498
500
  self.stop
499
501
  end
500
-
502
+
501
503
  if @should_restart
502
504
  loop do
503
505
  if @should_restart_done
504
506
  self.log_puts "Ending join because the restart is done." if @debug
505
507
  break
506
508
  end
507
-
509
+
508
510
  sleep 1
509
511
  end
510
512
  end
511
513
  end
512
-
514
+
513
515
  #Defines a variable as a method bound to the threads spawned by this instance of Hayabusa.
514
516
  def define_magic_var(method_name, var)
515
517
  @magic_vars[method_name] = var
516
-
518
+
517
519
  if !Object.respond_to?(method_name)
518
520
  Object.send(:define_method, method_name) do
519
521
  return Thread.current[:hayabusa][:hb].magic_vars[method_name] if Thread.current[:hayabusa] and Thread.current[:hayabusa][:hb]
@@ -521,11 +523,11 @@ class Hayabusa
521
523
  end
522
524
  end
523
525
  end
524
-
526
+
525
527
  def define_magic_proc(method_name, &block)
526
528
  raise "No block given." if !block_given?
527
529
  @magic_procs[method_name] = block
528
-
530
+
529
531
  if !Object.respond_to?(method_name)
530
532
  Object.send(:define_method, method_name) do
531
533
  return Thread.current[:hayabusa][:hb].magic_procs[method_name].call(:hb => self) if Thread.current[:hayabusa] and Thread.current[:hayabusa][:hb]
@@ -533,19 +535,19 @@ class Hayabusa
533
535
  end
534
536
  end
535
537
  end
536
-
538
+
537
539
  def translations
538
540
  if !@translations
539
541
  #Start the Knj::Gettext_threadded- and Knj::Translations modules for translations.
540
542
  self.log_puts "Spawning Knj::Translations-object." if @debug
541
543
  @translations = Knj::Translations.new(:db => @db)
542
-
544
+
543
545
  self.log_puts "Requires the translation-model." if @debug
544
546
  @ob.requireclass(:Translation, :require => false, :class => Knj::Translations::Translation)
545
547
  end
546
-
548
+
547
549
  self.log_puts "Returning the translations-object." if @debug
548
-
550
+
549
551
  return @translations
550
552
  end
551
553
  end