dango 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -166,6 +166,9 @@ class DangoServerFramework
166
166
  logger.warn("start drb server: uri=#{DRb.uri}")
167
167
  end
168
168
 
169
+ set_loop_setting(@loop_setting) if @loop_setting # ループ処理を定義
170
+
171
+
169
172
  @gserver = DangoGServer.new(self, @network_port, @server_host, @server_max_connections)
170
173
  @gserver.audit = true # Turn logging on.
171
174
  @gserver.debug = true # debug
@@ -473,7 +476,7 @@ EOF
473
476
  # 各種サーバー仕様の変数設定
474
477
  def set_server_variables()
475
478
  # 変数の初期設定
476
- @server_debug = @config['server']['debug'] || true
479
+ @thread_abort_on_exception = @config['server']['thread_abort_on_exception'] || true
477
480
 
478
481
  @network_port = @config['network']['port'] || DefaultNetworkPort
479
482
  @network_host = @config['network']['host'] || DefaultNetworkHost
@@ -510,6 +513,8 @@ EOF
510
513
  @backdoor_run_drb_port = @config['server']['backdoor_run_drb_port'] || 12345 # バックドア用のdrbサーバーのポート番号
511
514
  @backdoor_host = @config['server']['backdoor_host'] || '127.0.0.1' # バックドアのアクセス可能ホスト名
512
515
 
516
+ @loop_setting = @config['server']['loop_setting'] # メインループ用の定義
517
+
513
518
  # ログレベルの設定
514
519
  log_level_hash = {
515
520
  "FATAL" => Logger::FATAL,
@@ -528,7 +533,7 @@ EOF
528
533
  end
529
534
 
530
535
  # スレッド終了時に全体停止する
531
- Thread.abort_on_exception = true if @server_debug
536
+ Thread.abort_on_exception = true if @thread_abort_on_exception
532
537
 
533
538
  # 統計用情報の初期化
534
539
  @start_time = Time.now # サーバー起動時間
@@ -840,9 +845,43 @@ EOF
840
845
  end
841
846
 
842
847
  # メインループ用の定義をするためのメソッド
848
+ def set_loop_setting(options={})
849
+ logger.debug "loop_setting options:#{options.inspect}"
850
+ options = options.deep_dup
851
+
852
+ if options["method_name"] # メソッド名が無ければ処理しない
853
+ method_name = options["method_name"]
854
+
855
+ options["frame_rate"] ||= 5
856
+ wait_sec = 1.0 / options["frame_rate"]
857
+ logger.warn "set_loop_setting wait_sec:#{wait_sec.inspect} method_name=#{method_name}"
858
+
859
+ th = Thread.new do
860
+ begin
861
+ loop do
862
+ before_time = Time.now
863
+ @mutex_proc_thread.synchronize do
864
+ begin
865
+ __send__(method_name)
866
+ rescue Exception
867
+ logger.error "set_loop_setting error:#{error_message($!, 'u')}"
868
+ end
869
+ end
870
+
871
+ real_wait_sec = wait_sec - (Time.now - before_time)
872
+
873
+ sleep real_wait_sec if real_wait_sec > 0
874
+ end
875
+ rescue Exception
876
+ logger.error "set_loop_setting error:#{error_message($!, 'u')}"
877
+ end
878
+ end # th.end
879
+ end
880
+ end
881
+
882
+ =begin
843
883
  def flameloop_thread(loop_method, options={})
844
884
  logger.warn "flameloop_thread options:#{options.inspect}"
845
-
846
885
  options = options.deep_dup
847
886
  options[:rate] ||= 10
848
887
 
@@ -861,9 +900,8 @@ EOF
861
900
  sleep wait_sec
862
901
  end
863
902
  end
864
- # th.priority = 1
865
-
866
903
  end
904
+ =end
867
905
 
868
906
  end
869
907
 
data/lib/dango/version.rb CHANGED
@@ -2,7 +2,7 @@ module Dango #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 4
5
- TINY = 1
5
+ TINY = 2
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dango
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Keisuke Minami
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-09-17 00:00:00 +09:00
12
+ date: 2008-09-19 00:00:00 +09:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency