example/time_server in einhorn-0.8.2 vs example/time_server in einhorn-1.0.0
- old
+ new
@@ -10,19 +10,19 @@
# einhorn -b 127.0.0.1:2345,r ./time_server
#
# or, if you want to try out preloading:
#
# einhorn -b 127.0.0.1:2345,r -p ./time_server ./time_server
-require 'rubygems'
-require 'einhorn/worker'
+require "rubygems"
+require "einhorn/worker"
def log(msg)
puts "=== [#{$$}] #{msg}"
end
def einhorn_main
- log "Called with ENV['EINHORN_FD_0']: #{ENV['EINHORN_FD_0']}"
+ log "Called with ENV['EINHORN_FD_0']: #{ENV["EINHORN_FD_0"]}"
fd_num = Einhorn::Worker.socket!
socket = Socket.for_fd(fd_num)
sleep_before_shutdown = 0
@@ -47,15 +47,15 @@
Einhorn::Worker.ack!
# Real work happens here.
begin
- while true
+ loop do
accepted, _ = socket.accept
accepted.write("[#{$$}] The current time is: #{Time.now}!\n")
accepted.close
end
- rescue Exception
+ rescue Interrupt
end
end
if $0 == __FILE__
einhorn_main