eye 0.8.celluloid15 → 0.8.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (107) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +3 -5
  3. data/CHANGES.md +3 -7
  4. data/README.md +2 -5
  5. data/Rakefile +6 -6
  6. data/bin/leye +4 -9
  7. data/bin/loader_eye +15 -14
  8. data/examples/delayed_job.eye +3 -3
  9. data/examples/dependency.eye +11 -10
  10. data/examples/notify.eye +4 -3
  11. data/examples/plugin/main.eye +5 -5
  12. data/examples/plugin/plugin.rb +2 -10
  13. data/examples/process_thin.rb +8 -8
  14. data/examples/processes/em.rb +12 -18
  15. data/examples/processes/forking.rb +5 -5
  16. data/examples/processes/sample.rb +44 -46
  17. data/examples/puma.eye +8 -9
  18. data/examples/rbenv.eye +5 -5
  19. data/examples/sidekiq.eye +3 -3
  20. data/examples/stress_test.eye +4 -4
  21. data/examples/syslog.eye +1 -1
  22. data/examples/test.eye +2 -1
  23. data/examples/thin-farm.eye +8 -7
  24. data/examples/triggers.eye +15 -13
  25. data/examples/unicorn.eye +13 -12
  26. data/eye.gemspec +14 -16
  27. data/lib/eye.rb +3 -2
  28. data/lib/eye/application.rb +6 -5
  29. data/lib/eye/checker.rb +25 -44
  30. data/lib/eye/checker/children_count.rb +1 -1
  31. data/lib/eye/checker/file_ctime.rb +1 -1
  32. data/lib/eye/checker/http.rb +15 -13
  33. data/lib/eye/checker/nop.rb +0 -1
  34. data/lib/eye/checker/socket.rb +63 -60
  35. data/lib/eye/checker/ssl_socket.rb +5 -5
  36. data/lib/eye/child_process.rb +4 -6
  37. data/lib/eye/cli.rb +46 -74
  38. data/lib/eye/cli/commands.rb +5 -4
  39. data/lib/eye/cli/render.rb +41 -61
  40. data/lib/eye/cli/server.rb +16 -19
  41. data/lib/eye/client.rb +0 -1
  42. data/lib/eye/config.rb +33 -36
  43. data/lib/eye/controller.rb +3 -2
  44. data/lib/eye/controller/commands.rb +1 -1
  45. data/lib/eye/controller/helpers.rb +2 -2
  46. data/lib/eye/controller/load.rb +17 -19
  47. data/lib/eye/controller/options.rb +5 -1
  48. data/lib/eye/controller/send_command.rb +23 -21
  49. data/lib/eye/controller/status.rb +15 -17
  50. data/lib/eye/dsl.rb +1 -6
  51. data/lib/eye/dsl/application_opts.rb +3 -4
  52. data/lib/eye/dsl/chain.rb +2 -2
  53. data/lib/eye/dsl/child_process_opts.rb +3 -3
  54. data/lib/eye/dsl/config_opts.rb +7 -7
  55. data/lib/eye/dsl/group_opts.rb +3 -3
  56. data/lib/eye/dsl/helpers.rb +1 -1
  57. data/lib/eye/dsl/main.rb +3 -4
  58. data/lib/eye/dsl/opts.rb +28 -31
  59. data/lib/eye/dsl/process_opts.rb +7 -13
  60. data/lib/eye/dsl/pure_opts.rb +9 -13
  61. data/lib/eye/dsl/validation.rb +35 -48
  62. data/lib/eye/group.rb +8 -23
  63. data/lib/eye/group/chain.rb +6 -6
  64. data/lib/eye/loader.rb +3 -3
  65. data/lib/eye/local.rb +4 -9
  66. data/lib/eye/logger.rb +4 -11
  67. data/lib/eye/notify.rb +6 -10
  68. data/lib/eye/notify/jabber.rb +1 -1
  69. data/lib/eye/notify/mail.rb +2 -2
  70. data/lib/eye/notify/slack.rb +3 -4
  71. data/lib/eye/process.rb +0 -2
  72. data/lib/eye/process/children.rb +4 -4
  73. data/lib/eye/process/commands.rb +39 -38
  74. data/lib/eye/process/config.rb +16 -22
  75. data/lib/eye/process/controller.rb +19 -5
  76. data/lib/eye/process/data.rb +9 -11
  77. data/lib/eye/process/monitor.rb +76 -86
  78. data/lib/eye/process/notify.rb +10 -10
  79. data/lib/eye/process/scheduler.rb +31 -36
  80. data/lib/eye/process/states.rb +5 -7
  81. data/lib/eye/process/states_history.rb +3 -9
  82. data/lib/eye/process/system.rb +20 -35
  83. data/lib/eye/process/trigger.rb +5 -1
  84. data/lib/eye/process/watchers.rb +9 -12
  85. data/lib/eye/reason.rb +1 -4
  86. data/lib/eye/server.rb +1 -2
  87. data/lib/eye/system.rb +15 -22
  88. data/lib/eye/system_resources.rb +9 -18
  89. data/lib/eye/trigger.rb +16 -18
  90. data/lib/eye/trigger/check_dependency.rb +4 -7
  91. data/lib/eye/trigger/flapping.rb +7 -24
  92. data/lib/eye/trigger/starting_guard.rb +6 -7
  93. data/lib/eye/trigger/stop_children.rb +2 -2
  94. data/lib/eye/trigger/transition.rb +1 -1
  95. data/lib/eye/trigger/wait_dependency.rb +2 -3
  96. data/lib/eye/utils.rb +3 -4
  97. data/lib/eye/utils/alive_array.rb +4 -9
  98. data/lib/eye/utils/celluloid_chain.rb +10 -12
  99. data/lib/eye/utils/leak_19.rb +10 -0
  100. data/lib/eye/utils/mini_active_support.rb +16 -16
  101. data/lib/eye/utils/pmap.rb +0 -2
  102. data/lib/eye/utils/tail.rb +2 -2
  103. metadata +8 -39
  104. data/.rubocop.yml +0 -141
  105. data/examples/custom_check.eye +0 -24
  106. data/examples/custom_trigger.eye +0 -30
  107. data/examples/leye_example/Eyefile +0 -10
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 39b53d19c30acc0229dfdec07e5c135d8cc997fc
4
- data.tar.gz: 82f8d45c31474a83b479376922899f39cfe9e232
3
+ metadata.gz: 4ea3a96041c3e00aa9a2844e50fa3b5c0be453c6
4
+ data.tar.gz: 8c81af5c7d106a079cfc49023b16472bf78600ad
5
5
  SHA512:
6
- metadata.gz: 30546ea03294ca6ad90a9f6cc6ed82aeacd386163759a08f6ab51051234835eef9591a73b934eb91f0701574e57b016ff7ca8437990a00f826bc7b5bdad3edde
7
- data.tar.gz: 23e7c50c282eefa9a41420d07704007dc18fc1f1ddfa804f56a659263115db76031be59686dac00499da1eda51db03891b9fa34cc7f6e624f87cb01ce69fd782
6
+ metadata.gz: dc19f2831994ee9bba061abb1d374d928f8687d1fd39b78e18281d9a8c688a02aec672bf949a5e40fbc024507fb2dfc274374c917fe89f76afd9398e7bfd1411
7
+ data.tar.gz: 71b61401efa1a893d781e561c73554ba165b3984de5bc9b359adcaf51cf0e6d18bfb7aade77816dae326a29142b15be57c0e1ba34f1b78776025908b9bd7a5e4
@@ -2,8 +2,6 @@ language: ruby
2
2
  rvm:
3
3
  - "1.9.3"
4
4
  - "2.0.0"
5
- - "2.1.7"
6
- - "2.2.3"
7
- script:
8
- - bundle exec rake N=16
9
- - bundle exec rubocop
5
+ - "2.1"
6
+ - "2.2.2"
7
+ script: bundle exec rake split_test N=15
data/CHANGES.md CHANGED
@@ -1,10 +1,6 @@
1
- 0.8
1
+ 0.8.pre
2
2
  -------
3
- * info, xinfo, oinfo, history now support -j flag, to output json
4
- * leye: many fixes (--eyehome, --eyefile)
5
- * add flapping reretry_in (#152)
6
- * add check_identity of processes, avoid many bugs with wrong pid_files, or auto changed pids (#62)
7
- * update Celluloid to 0.17
3
+ * Update Celluloid to 0.17.0
8
4
 
9
5
  0.7
10
6
  -------
@@ -21,7 +17,7 @@
21
17
  * some fixes in flapping
22
18
  * add proxy_url to http check
23
19
  * process with children, shows children history now
24
- * update Celluloid to 0.16
20
+ * Update Celluloid to 0.16.0
25
21
 
26
22
  0.6.4
27
23
  -----
data/README.md CHANGED
@@ -98,7 +98,7 @@ Eye.application 'test' do
98
98
  end
99
99
 
100
100
  # eventmachine process, daemonized with eye
101
- process :event_machine do
101
+ process :event_machine do |p|
102
102
  pid_file 'em.pid'
103
103
  start_command 'ruby em.rb'
104
104
  stdout 'em.log'
@@ -118,6 +118,7 @@ Eye.application 'test' do
118
118
  check :http, url: 'http://127.0.0.1:33233/hello', pattern: /World/,
119
119
  every: 5.seconds, times: [2, 3], timeout: 1.second
120
120
  end
121
+
121
122
  end
122
123
  ```
123
124
 
@@ -136,10 +137,6 @@ foreground load:
136
137
 
137
138
  If the eye daemon has already started and you call the `load` command, the config will be updated (into eye daemon). New objects(applications, groups, processes) will be added and monitored. Processes removed from the config will be removed (and stopped if the process has `stop_on_delete true`). Other objects will update their configs.
138
139
 
139
- Two global configs loaded by default, if it exists (with the first eye load):
140
-
141
- /etc/eye.conf
142
- ~/.eyeconfig
143
140
 
144
141
  Process statuses:
145
142
 
data/Rakefile CHANGED
@@ -1,21 +1,21 @@
1
1
  #!/usr/bin/env rake
2
2
 
3
- require 'bundler/gem_tasks'
3
+ require "bundler/gem_tasks"
4
4
  require 'rspec/core/rake_task'
5
5
  require 'coveralls/rake/task'
6
6
 
7
7
  Coveralls::RakeTask.new
8
8
 
9
- task :default => :split_test
9
+ task :default => :pspec
10
10
 
11
- desc 'run parallel tests'
11
+ desc "run parallel tests"
12
12
  task :pspec do
13
13
  dirname = File.expand_path(File.dirname(__FILE__))
14
14
  cmd = "bundle exec parallel_rspec -n #{ENV['N'] || 10} --runtime-log '#{dirname}/spec/weights.txt' #{dirname}/spec"
15
15
  abort unless system(cmd)
16
16
  end
17
17
 
18
- desc 'run parallel split tests'
18
+ desc "run parallel split tests"
19
19
  task :split_test do
20
20
  dirname = File.expand_path(File.dirname(__FILE__))
21
21
  ENV['PARALLEL_SPLIT_TEST_PROCESSES'] = (ENV['N'] || 10).to_s
@@ -39,7 +39,7 @@ task :env do
39
39
  Eye::Process
40
40
  end
41
41
 
42
- desc 'graph'
42
+ desc "graph"
43
43
  task :graph => :env do
44
- StateMachine::Machine.draw('Eye::Process')
44
+ StateMachine::Machine.draw("Eye::Process")
45
45
  end
data/bin/leye CHANGED
@@ -6,7 +6,7 @@ require 'eye'
6
6
  # which looking for Eyefile
7
7
  # like foreman
8
8
 
9
- loop do
9
+ while true
10
10
  if ARGV[0] == '--eyefile'
11
11
  ARGV.shift
12
12
  ENV['EYE_FILE'] = File.expand_path(ARGV.shift.to_s)
@@ -18,18 +18,13 @@ loop do
18
18
  end
19
19
  end
20
20
 
21
- if ENV['EYE_HOME'] && !File.directory?(File.expand_path(ENV['EYE_HOME']))
22
- puts "\033[31mEYE_HOME is not directory (#{File.expand_path(ENV['EYE_HOME'])})\033[0m"
23
- exit 1
24
- end
25
-
26
- unless Eye::Local.eyefile || ENV['EYE_HOME']
27
- puts "\033[31mNot found Eyefile (in #{File.expand_path(ENV['EYE_HOME'] || '.')})\033[0m"
21
+ unless Eye::Local.eyefile
22
+ puts "\033[31mNot found Eyefile (in #{File.expand_path('.')})\033[0m"
28
23
  exit 1
29
24
  end
30
25
 
31
26
  unless ENV.key?('EYE_HOME')
32
- ENV['EYE_HOME'] = File.dirname(Eye::Local.eyefile)
27
+ Eye::Local.dir = File.join(File.dirname(Eye::Local.eyefile), '.eye')
33
28
  end
34
29
 
35
30
  Eye::Local.local_runner = true
@@ -4,38 +4,39 @@ require 'eye/loader'
4
4
  require 'optparse'
5
5
  require 'eye'
6
6
 
7
- options = { debug: false }
7
+ options = {:debug => false}
8
8
 
9
9
  OptionParser.new do |opts|
10
- opts.on('-h', '--help', 'Display this screen') do
10
+ opts.on( '-h', '--help', 'Display this screen' ) do
11
11
  puts opts
12
12
  exit
13
13
  end
14
14
 
15
- opts.on('-c', '--config CONFIG', 'load with config') do |config_path|
15
+ opts.on( '-c', '--config CONFIG', 'load with config' ) do |config_path|
16
16
  options[:config] = config_path
17
17
  end
18
18
 
19
- opts.on('-s', '--socket SOCKET', 'start listen on socket') do |socket_path|
19
+ opts.on( '-s', '--socket SOCKET', 'start listen on socket' ) do |socket_path|
20
20
  options[:socket_path] = socket_path
21
21
  end
22
22
 
23
- opts.on('-l', '--logger LOGGER', 'custom logger') do |logger|
23
+ opts.on( '-l', '--logger LOGGER', 'custom logger' ) do |logger|
24
24
  options[:logger] = logger
25
25
  end
26
26
 
27
- opts.on('-d', '--dir DIR', 'Dir for local runner') do |dir|
27
+ opts.on( '-dr', '--dir DIR', 'Dir for local runner' ) do |dir|
28
28
  Eye::Local.dir = dir
29
29
  Eye::Local.local_runner = true
30
30
  end
31
31
 
32
- opts.on('-a', '--stop_all', 'Stop all on exit') do
32
+ opts.on( '-st', '--stop_all', 'Stop all on exit' ) do |stop_all|
33
33
  options[:stop_all] = true
34
34
  end
35
35
 
36
- opts.on('-g', '--debug', 'debug info to logger') do
36
+ opts.on( '-d', '--debug', 'debug info to logger' ) do
37
37
  options[:debug] = true
38
38
  end
39
+
39
40
  end.parse!
40
41
 
41
42
  Eye::Local.ensure_eye_dir
@@ -60,12 +61,12 @@ Eye::Control.set_proc_line
60
61
 
61
62
  server.async.run
62
63
 
63
- trap('USR1') { Eye::Logger.reopen }
64
- trap('USR2') { GC.start }
64
+ trap("USR1") { Eye::Logger.reopen }
65
+ trap("USR2") { GC.start }
66
+ trap("INT") { Eye::Logger.info("INT signal <#{$$}>"); exit }
67
+ trap("QUIT") { Eye::Logger.info("QUIT signal <#{$$}>"); exit }
68
+ trap("TERM") { Eye::Logger.info("TERM signal <#{$$}>"); exit }
65
69
 
66
70
  at_exit { Eye::Control.command(:stop_all) } if options[:stop_all]
67
71
 
68
- begin
69
- sleep
70
- rescue Interrupt
71
- end
72
+ sleep
@@ -1,6 +1,6 @@
1
1
  cwd = File.expand_path(File.join(File.dirname(__FILE__), %w[ ../ ../ ]))
2
2
 
3
- config_path = File.join(cwd, %w[ config dj.yml ])
3
+ config_path = File.join(cwd, %w{ config dj.yml } )
4
4
 
5
5
  workers_count = if File.exist?(config_path)
6
6
  YAML.load_file(config_path).try(:[], :workers) || 5
@@ -15,10 +15,10 @@ Eye.application 'delayed_job' do
15
15
  group 'dj' do
16
16
  chain grace: 5.seconds
17
17
 
18
- (1..workers_count).each do |i|
18
+ (1 .. workers_count).each do |i|
19
19
  process "dj-#{i}" do
20
20
  pid_file "tmp/pids/delayed_job.#{i}.pid"
21
- start_command 'rake jobs:work'
21
+ start_command "rake jobs:work"
22
22
  daemonize true
23
23
  stop_signals [:INT, 30.seconds, :TERM, 10.seconds, :KILL]
24
24
  stdall "log/dj-#{i}.log"
@@ -2,36 +2,37 @@
2
2
 
3
3
  Eye.app :dependency do
4
4
  process(:a) do
5
- start_command 'sleep 100'
5
+ start_command "sleep 100"
6
6
  daemonize true
7
- pid_file '/tmp/test_process_a.pid'
7
+ pid_file "/tmp/test_process_a.pid"
8
8
  end
9
9
 
10
10
  process(:b) do
11
- start_command 'sleep 100'
11
+ start_command "sleep 100"
12
12
  daemonize true
13
- pid_file '/tmp/test_process_b.pid'
13
+ pid_file "/tmp/test_process_b.pid"
14
14
  depend_on :a
15
15
  end
16
16
 
17
17
  process(:c) do
18
- start_command 'sleep 100'
18
+ start_command "sleep 100"
19
19
  daemonize true
20
- pid_file '/tmp/test_process_c.pid'
20
+ pid_file "/tmp/test_process_c.pid"
21
21
  depend_on :a
22
22
  end
23
23
 
24
24
  process(:d) do
25
- start_command 'sleep 100'
25
+ start_command "sleep 100"
26
26
  daemonize true
27
- pid_file '/tmp/test_process_d.pid'
27
+ pid_file "/tmp/test_process_d.pid"
28
28
  depend_on :b
29
29
  end
30
30
 
31
31
  process(:e) do
32
- start_command 'sleep 100'
32
+ start_command "sleep 100"
33
33
  daemonize true
34
- pid_file '/tmp/test_process_e.pid'
34
+ pid_file "/tmp/test_process_e.pid"
35
35
  depend_on [:d, :c]
36
36
  end
37
+
37
38
  end
@@ -1,7 +1,7 @@
1
1
  # Notify example
2
2
 
3
3
  Eye.config do
4
- mail host: 'mx.some.host', port: 25, domain: 'some.host'
4
+ mail :host => "mx.some.host", :port => 25, :domain => "some.host"
5
5
  contact :errors, :mail, 'error@some.host'
6
6
  contact :dev, :mail, 'dev@some.host'
7
7
  end
@@ -11,8 +11,9 @@ Eye.application :some do
11
11
 
12
12
  process :some_process do
13
13
  notify :dev, :info
14
- pid_file '1.pid'
14
+ pid_file "1.pid"
15
15
 
16
- # ...
16
+ #...
17
17
  end
18
+
18
19
  end
@@ -1,15 +1,15 @@
1
1
  Eye.load('./plugin.rb')
2
2
 
3
3
  Eye.config do
4
- logger '/tmp/eye.log'
5
- enable_reactor(1.second, '/tmp/cmd.txt')
6
- enable_saver('/tmp/saver.log')
4
+ logger "/tmp/eye.log"
5
+ enable_reactor(1.second, "/tmp/cmd.txt")
6
+ enable_saver("/tmp/saver.log")
7
7
  end
8
8
 
9
9
  Eye.app :app do
10
10
  process :process do
11
- pid_file '/tmp/p.pid'
12
- start_command 'sleep 10'
11
+ pid_file "/tmp/p.pid"
12
+ start_command "sleep 10"
13
13
  daemonize true
14
14
  end
15
15
  end
@@ -1,5 +1,4 @@
1
1
  class Reactor
2
-
3
2
  include Celluloid
4
3
 
5
4
  def initialize(interval, filename)
@@ -22,13 +21,11 @@ class Reactor
22
21
  end
23
22
 
24
23
  def execute_command(cmd)
25
- Eye::Control.command(cmd, 'all') if %w[restart start stop].include?(cmd)
24
+ Eye::Control.command(cmd, 'all') if %w{restart start stop}.include?(cmd)
26
25
  end
27
-
28
26
  end
29
27
 
30
28
  class Saver < Eye::Trigger::Custom
31
-
32
29
  param :log_name, String, true
33
30
 
34
31
  def check(trans)
@@ -38,7 +35,6 @@ class Saver < Eye::Trigger::Custom
38
35
  def tlogger
39
36
  @tlogger ||= Logger.new(log_name)
40
37
  end
41
-
42
38
  end
43
39
 
44
40
  def reactor
@@ -47,25 +43,21 @@ end
47
43
 
48
44
  # Extend config options, add enable_reactor
49
45
  class Eye::Dsl::ConfigOpts
50
-
51
46
  def enable_reactor(*args)
52
47
  @config[:reactor] = args
53
48
  end
54
49
 
55
50
  def enable_saver(save_log)
56
51
  Eye.application '__default__' do
57
- trigger :saver, log_name: save_log
52
+ trigger :saver, :log_name => save_log
58
53
  end
59
54
  end
60
-
61
55
  end
62
56
 
63
57
  # extend controller to execute method, and config loads
64
58
  class Eye::Controller
65
-
66
59
  def set_opt_reactor(args)
67
60
  reactor.terminate if reactor
68
61
  Celluloid::Actor[:reactor] = Reactor.supervise(*args)
69
62
  end
70
-
71
63
  end
@@ -4,16 +4,16 @@ def thin(proxy, port)
4
4
  name = "thin-#{port}"
5
5
 
6
6
  opts = [
7
- '-l thins.log',
7
+ "-l thins.log",
8
8
  "-p #{port}",
9
9
  "-P #{name}.pid",
10
- '-d',
11
- '-R thin.ru',
10
+ "-d",
11
+ "-R thin.ru",
12
12
  "--tag #{proxy.app.name}.#{proxy.name}",
13
- '-t 60',
13
+ "-t 60",
14
14
  "-e #{proxy.env['RAILS_ENV']}",
15
15
  "-c #{proxy.working_dir}",
16
- '-a 127.0.0.1'
16
+ "-a 127.0.0.1"
17
17
  ]
18
18
 
19
19
  proxy.process(name) do
@@ -22,9 +22,9 @@ def thin(proxy, port)
22
22
  start_command "#{BUNDLE} exec thin start #{opts * ' '}"
23
23
  stop_signals [:QUIT, 2.seconds, :TERM, 1.seconds, :KILL]
24
24
 
25
- stdall 'thin.stdall.log'
25
+ stdall "thin.stdall.log"
26
26
 
27
- check :http, url: "http://127.0.0.1:#{port}/hello", pattern: /World/,
28
- every: 5.seconds, times: [2, 3], timeout: 1.second
27
+ check :http, :url => "http://127.0.0.1:#{port}/hello", :pattern => /World/,
28
+ :every => 5.seconds, :times => [2, 3], :timeout => 1.second
29
29
  end
30
30
  end
@@ -5,9 +5,7 @@ def answer(data)
5
5
  case data
6
6
  when 'ping' then "pong\n"
7
7
  when 'bad' then "what\n"
8
- when 'timeout' then
9
- sleep 5
10
- "ok\n"
8
+ when 'timeout' then sleep 5; "ok\n"
11
9
  when 'exception' then raise 'haha'
12
10
  when 'quit' then EM.stop
13
11
  when 'big' then 'a' * 10_000_000
@@ -15,49 +13,45 @@ def answer(data)
15
13
  end
16
14
 
17
15
  class Echo < EM::Connection
18
-
19
16
  def post_init
20
- puts '-- someone connected to the echo server!'
17
+ puts "-- someone connected to the echo server!"
21
18
  end
22
19
 
23
- def receive_data(data)
20
+ def receive_data data
24
21
  puts "receive #{data.inspect} "
25
22
  send_data(answer(data))
26
23
  end
27
24
 
28
25
  def unbind
29
- puts '-- someone disconnected from the echo server!'
26
+ puts "-- someone disconnected from the echo server!"
30
27
  end
31
-
32
28
  end
33
29
 
34
30
  class EchoObj < EM::Connection
35
-
36
31
  include EM::P::ObjectProtocol
37
32
 
38
33
  def post_init
39
- puts '-- someone connected to the echo server!'
34
+ puts "-- someone connected to the echo server!"
40
35
  end
41
36
 
42
- def receive_object(obj) # {:command => 'ping'}
37
+ def receive_object obj # {:command => 'ping'}
43
38
  puts "receive #{obj.inspect}"
44
39
  send_object(answer(obj[:command]).chop)
45
40
  end
46
41
 
47
42
  def unbind
48
- puts '-- someone disconnected from the echo server!'
43
+ puts "-- someone disconnected from the echo server!"
49
44
  end
50
-
51
45
  end
52
46
 
53
- trap 'QUIT' do
54
- puts 'quit signal, stopping'
47
+ trap "QUIT" do
48
+ puts "quit signal, stopping"
55
49
  EM.stop
56
50
  end
57
51
 
58
52
  EM.run do
59
- EM.start_server '127.0.0.1', 33_221, Echo
60
- EM.start_server '127.0.0.1', 33_222, EchoObj
61
- EM.start_server '/tmp/em_test_sock', nil, Echo
53
+ EM.start_server '127.0.0.1', 33221, Echo
54
+ EM.start_server '127.0.0.1', 33222, EchoObj
55
+ EM.start_server "/tmp/em_test_sock", nil, Echo
62
56
  puts 'started'
63
57
  end