Skip to content

Commit

Permalink
Merge pull request #47 from okkez/suppress-warnings
Browse files Browse the repository at this point in the history
Suppress Ruby warnings
  • Loading branch information
naritta committed May 19, 2016
2 parents 2346863 + 17275d0 commit ba93820
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 82 deletions.
2 changes: 2 additions & 0 deletions lib/serverengine/config_loader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ def initialize(load_config_proc={}, &block)
end
end

@logger = nil

reload_config
end

Expand Down
4 changes: 2 additions & 2 deletions lib/serverengine/daemon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ def initialize(server_module, worker_module, load_config_proc={}, &block)
@daemonize = @config.fetch(:daemonize, false)

if @config.fetch(:supervisor, false)
@create_server_proc = lambda do |load_config_proc,logger|
s = Supervisor.new(server_module, worker_module, load_config_proc)
@create_server_proc = lambda do |_load_config_proc,logger|
s = Supervisor.new(server_module, worker_module, _load_config_proc)
s.logger = logger
s
end
Expand Down
1 change: 1 addition & 0 deletions lib/serverengine/daemon_logger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class DaemonLogger < Logger
def initialize(logdev, config={})
@rotate_age = config[:log_rotate_age] || 5
@rotate_size = config[:log_rotate_size] || 1048576
@file_dev = nil

if RUBY_VERSION < "2.1.0"
# Ruby < 2.1.0 has a problem around log rotation with multiprocess:
Expand Down
2 changes: 1 addition & 1 deletion lib/serverengine/supervisor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def main
while true
# keep the child process alive in this loop
until @detach_flag.wait(0.5)
if stat = try_join
if try_join
return if @stop # supervisor stoppped explicitly

# child process died unexpectedly.
Expand Down
143 changes: 71 additions & 72 deletions spec/server_worker_context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,101 +29,100 @@ def test_state(key)
return data[key] || 0
end

shared_context 'test server and worker' do
before { reset_test_state }

def wait_for_fork
sleep 0.8
module TestServer
def initialize
incr_test_state :server_initialize
end

def wait_for_stop
sleep 0.8
def before_run
incr_test_state :server_before_run
end

def wait_for_restart
sleep 1.5
def after_run
incr_test_state :server_after_run
end

module TestServer
def initialize
incr_test_state :server_initialize
end
def after_start
incr_test_state :server_after_start
end

def before_run
incr_test_state :server_before_run
def stop(stop_graceful)
incr_test_state :server_stop
if stop_graceful
incr_test_state :server_stop_graceful
else
incr_test_state :server_stop_immediate
end
super
end

def after_run
incr_test_state :server_after_run
def restart(stop_graceful)
incr_test_state :server_restart
if stop_graceful
incr_test_state :server_restart_graceful
else
incr_test_state :server_restart_immediate
end
super
end

def after_start
incr_test_state :server_after_start
end
def reload
incr_test_state :server_reload
super
end

def stop(stop_graceful)
incr_test_state :server_stop
if stop_graceful
incr_test_state :server_stop_graceful
else
incr_test_state :server_stop_immediate
end
super
end
def detach
incr_test_state :server_detach
super
end
end

def restart(stop_graceful)
incr_test_state :server_restart
if stop_graceful
incr_test_state :server_restart_graceful
else
incr_test_state :server_restart_immediate
end
super
end
module TestWorker
def initialize
incr_test_state :worker_initialize
@stop_flag = BlockingFlag.new
end

def reload
incr_test_state :server_reload
super
end
def before_fork
incr_test_state :worker_before_fork
end

def detach
incr_test_state :server_detach
super
def run
incr_test_state :worker_run
5.times do
# repeats 5 times because signal handlers
# interrupts wait
@stop_flag.wait(5.0)
end
@stop_flag.reset!
end

module TestWorker
def initialize
incr_test_state :worker_initialize
@stop_flag = BlockingFlag.new
end
def stop
incr_test_state :worker_stop
@stop_flag.set!
end

def before_fork
incr_test_state :worker_before_fork
end
def reload
incr_test_state :worker_reload
end

def run
incr_test_state :worker_run
5.times do
# repeats 5 times because signal handlers
# interrupts wait
@stop_flag.wait(5.0)
end
@stop_flag.reset!
end
def after_start
incr_test_state :worker_after_start
end
end

def stop
incr_test_state :worker_stop
@stop_flag.set!
end
shared_context 'test server and worker' do
before { reset_test_state }

def reload
incr_test_state :worker_reload
end
def wait_for_fork
sleep 0.8
end

def after_start
incr_test_state :worker_after_start
end
def wait_for_stop
sleep 0.8
end

def wait_for_restart
sleep 1.5
end
end
6 changes: 2 additions & 4 deletions spec/signal_thread_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
it 'signal in handler' do
n = 0

t = SignalThread.new do |st|
SignalThread.new do |st|
st.trap('QUIT') do
if n < 3
Process.kill('QUIT', Process.pid)
Expand All @@ -55,8 +55,6 @@
end

it 'stop in handler' do
n = 0

t = SignalThread.new do |st|
st.trap('QUIT') { st.stop }
end
Expand All @@ -70,7 +68,7 @@
it 'should not deadlock' do
n = 0

t = SignalThread.new do |st|
SignalThread.new do |st|
st.trap('CONT') { n += 1 }
end

Expand Down
6 changes: 3 additions & 3 deletions spec/socket_manager_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
end

after(:each) do
File.unlink(server_path) if File.exists?(server_path)
File.unlink(server_path) if File.exist?(server_path)
end

if ServerEngine.windows?
Expand Down Expand Up @@ -37,7 +37,7 @@
incr_test_state(:is_tcp_server) if tcp.is_a?(TCPServer)
incr_test_state(:is_udp_socket) if udp.is_a?(UDPSocket)

data, from = udp.recvfrom(10)
data, _from = udp.recvfrom(10)
incr_test_state(:udp_data_sent) if data == "ok"

s = tcp.accept
Expand Down Expand Up @@ -89,7 +89,7 @@
incr_test_state(:is_tcp_server) if tcp.is_a?(TCPServer)
incr_test_state(:is_udp_socket) if udp.is_a?(UDPSocket)

data, from = udp.recvfrom(10)
data, _from = udp.recvfrom(10)
incr_test_state(:udp_data_sent) if data == "ok"

s = tcp.accept
Expand Down

0 comments on commit ba93820

Please sign in to comment.