eye 0.1.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (190) hide show
  1. data/.gitignore +31 -0
  2. data/.rspec +2 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE +22 -0
  5. data/README.md +132 -0
  6. data/Rakefile +18 -0
  7. data/bin/eye +282 -0
  8. data/bin/loader_eye +56 -0
  9. data/examples/processes/em.rb +56 -0
  10. data/examples/processes/forking.rb +20 -0
  11. data/examples/processes/sample.rb +144 -0
  12. data/examples/rbenv.eye +11 -0
  13. data/examples/test.eye +65 -0
  14. data/examples/unicorn.eye +29 -0
  15. data/eye.gemspec +37 -0
  16. data/lib/eye.rb +25 -0
  17. data/lib/eye/application.rb +65 -0
  18. data/lib/eye/checker.rb +118 -0
  19. data/lib/eye/checker/cpu.rb +27 -0
  20. data/lib/eye/checker/file_ctime.rb +29 -0
  21. data/lib/eye/checker/file_size.rb +38 -0
  22. data/lib/eye/checker/http.rb +94 -0
  23. data/lib/eye/checker/memory.rb +27 -0
  24. data/lib/eye/checker/socket.rb +148 -0
  25. data/lib/eye/checker/validation.rb +49 -0
  26. data/lib/eye/child_process.rb +75 -0
  27. data/lib/eye/client.rb +32 -0
  28. data/lib/eye/control.rb +2 -0
  29. data/lib/eye/controller.rb +43 -0
  30. data/lib/eye/controller/commands.rb +64 -0
  31. data/lib/eye/controller/helpers.rb +61 -0
  32. data/lib/eye/controller/load.rb +224 -0
  33. data/lib/eye/controller/send_command.rb +88 -0
  34. data/lib/eye/controller/status.rb +136 -0
  35. data/lib/eye/dsl.rb +52 -0
  36. data/lib/eye/dsl/application_opts.rb +33 -0
  37. data/lib/eye/dsl/chain.rb +12 -0
  38. data/lib/eye/dsl/child_process_opts.rb +7 -0
  39. data/lib/eye/dsl/config_opts.rb +11 -0
  40. data/lib/eye/dsl/group_opts.rb +27 -0
  41. data/lib/eye/dsl/helpers.rb +12 -0
  42. data/lib/eye/dsl/main.rb +58 -0
  43. data/lib/eye/dsl/opts.rb +88 -0
  44. data/lib/eye/dsl/process_opts.rb +21 -0
  45. data/lib/eye/dsl/pure_opts.rb +132 -0
  46. data/lib/eye/dsl/validate.rb +41 -0
  47. data/lib/eye/group.rb +125 -0
  48. data/lib/eye/group/chain.rb +68 -0
  49. data/lib/eye/io/unix_server.rb +44 -0
  50. data/lib/eye/io/unix_socket.rb +39 -0
  51. data/lib/eye/loader.rb +13 -0
  52. data/lib/eye/logger.rb +80 -0
  53. data/lib/eye/process.rb +83 -0
  54. data/lib/eye/process/child.rb +61 -0
  55. data/lib/eye/process/commands.rb +256 -0
  56. data/lib/eye/process/config.rb +70 -0
  57. data/lib/eye/process/controller.rb +72 -0
  58. data/lib/eye/process/data.rb +46 -0
  59. data/lib/eye/process/monitor.rb +97 -0
  60. data/lib/eye/process/notify.rb +17 -0
  61. data/lib/eye/process/scheduler.rb +50 -0
  62. data/lib/eye/process/states.rb +92 -0
  63. data/lib/eye/process/states_history.rb +62 -0
  64. data/lib/eye/process/system.rb +60 -0
  65. data/lib/eye/process/trigger.rb +32 -0
  66. data/lib/eye/process/watchers.rb +67 -0
  67. data/lib/eye/server.rb +51 -0
  68. data/lib/eye/settings.rb +35 -0
  69. data/lib/eye/system.rb +145 -0
  70. data/lib/eye/system_resources.rb +83 -0
  71. data/lib/eye/trigger.rb +53 -0
  72. data/lib/eye/trigger/flapping.rb +24 -0
  73. data/lib/eye/utils.rb +5 -0
  74. data/lib/eye/utils/alive_array.rb +31 -0
  75. data/lib/eye/utils/celluloid_chain.rb +51 -0
  76. data/lib/eye/utils/leak_19.rb +7 -0
  77. data/lib/eye/utils/tail.rb +20 -0
  78. data/spec/checker/cpu_spec.rb +58 -0
  79. data/spec/checker/file_ctime_spec.rb +34 -0
  80. data/spec/checker/file_size_spec.rb +107 -0
  81. data/spec/checker/http_spec.rb +109 -0
  82. data/spec/checker/memory_spec.rb +64 -0
  83. data/spec/checker/socket_spec.rb +116 -0
  84. data/spec/checker_spec.rb +188 -0
  85. data/spec/child_process/child_process_spec.rb +46 -0
  86. data/spec/client_server_spec.rb +34 -0
  87. data/spec/controller/commands_spec.rb +92 -0
  88. data/spec/controller/controller_spec.rb +133 -0
  89. data/spec/controller/find_objects_spec.rb +150 -0
  90. data/spec/controller/group_spec.rb +110 -0
  91. data/spec/controller/intergration_spec.rb +327 -0
  92. data/spec/controller/load_spec.rb +326 -0
  93. data/spec/controller/races_spec.rb +70 -0
  94. data/spec/controller/stop_on_delete_spec.rb +157 -0
  95. data/spec/dsl/chain_spec.rb +140 -0
  96. data/spec/dsl/checks_spec.rb +202 -0
  97. data/spec/dsl/config_spec.rb +44 -0
  98. data/spec/dsl/dsl_spec.rb +73 -0
  99. data/spec/dsl/getter_spec.rb +223 -0
  100. data/spec/dsl/integration_spec.rb +311 -0
  101. data/spec/dsl/load_spec.rb +52 -0
  102. data/spec/dsl/process_spec.rb +330 -0
  103. data/spec/dsl/sub_procs_spec.rb +93 -0
  104. data/spec/dsl/with_server_spec.rb +104 -0
  105. data/spec/example/em.rb +57 -0
  106. data/spec/example/forking.rb +20 -0
  107. data/spec/example/sample.rb +154 -0
  108. data/spec/fixtures/dsl/0.rb +8 -0
  109. data/spec/fixtures/dsl/0a.rb +8 -0
  110. data/spec/fixtures/dsl/0c.rb +8 -0
  111. data/spec/fixtures/dsl/1.rb +5 -0
  112. data/spec/fixtures/dsl/bad.eye +6 -0
  113. data/spec/fixtures/dsl/configs/1.eye +3 -0
  114. data/spec/fixtures/dsl/configs/2.eye +1 -0
  115. data/spec/fixtures/dsl/configs/3.eye +1 -0
  116. data/spec/fixtures/dsl/configs/4.eye +3 -0
  117. data/spec/fixtures/dsl/empty.eye +20 -0
  118. data/spec/fixtures/dsl/include_test.eye +5 -0
  119. data/spec/fixtures/dsl/include_test/1.rb +6 -0
  120. data/spec/fixtures/dsl/include_test/ha.rb +4 -0
  121. data/spec/fixtures/dsl/include_test2.eye +5 -0
  122. data/spec/fixtures/dsl/integration.eye +30 -0
  123. data/spec/fixtures/dsl/integration2.eye +32 -0
  124. data/spec/fixtures/dsl/integration_locks.eye +30 -0
  125. data/spec/fixtures/dsl/integration_sor.eye +32 -0
  126. data/spec/fixtures/dsl/integration_sor2.eye +27 -0
  127. data/spec/fixtures/dsl/integration_sor3.eye +32 -0
  128. data/spec/fixtures/dsl/load.eye +25 -0
  129. data/spec/fixtures/dsl/load2.eye +7 -0
  130. data/spec/fixtures/dsl/load2_dup2.eye +13 -0
  131. data/spec/fixtures/dsl/load2_dup_pid.eye +7 -0
  132. data/spec/fixtures/dsl/load3.eye +10 -0
  133. data/spec/fixtures/dsl/load4.eye +7 -0
  134. data/spec/fixtures/dsl/load5.eye +8 -0
  135. data/spec/fixtures/dsl/load6.eye +17 -0
  136. data/spec/fixtures/dsl/load_dubls.eye +36 -0
  137. data/spec/fixtures/dsl/load_dup_ex_names.eye +15 -0
  138. data/spec/fixtures/dsl/load_error.eye +5 -0
  139. data/spec/fixtures/dsl/load_error_folder/load3.eye +10 -0
  140. data/spec/fixtures/dsl/load_error_folder/load4.eye +7 -0
  141. data/spec/fixtures/dsl/load_folder/load3.eye +10 -0
  142. data/spec/fixtures/dsl/load_folder/load4.eye +7 -0
  143. data/spec/fixtures/dsl/load_int.eye +8 -0
  144. data/spec/fixtures/dsl/load_int2.eye +13 -0
  145. data/spec/fixtures/dsl/load_logger.eye +26 -0
  146. data/spec/fixtures/dsl/load_logger2.eye +3 -0
  147. data/spec/fixtures/dsl/long_load.eye +5 -0
  148. data/spec/fixtures/dsl/subfolder1/proc1.rb +3 -0
  149. data/spec/fixtures/dsl/subfolder2.eye +9 -0
  150. data/spec/fixtures/dsl/subfolder2/common.rb +1 -0
  151. data/spec/fixtures/dsl/subfolder2/proc2.rb +3 -0
  152. data/spec/fixtures/dsl/subfolder2/sub/proc3.rb +6 -0
  153. data/spec/fixtures/dsl/subfolder3.eye +8 -0
  154. data/spec/fixtures/dsl/subfolder3/common.rb +1 -0
  155. data/spec/fixtures/dsl/subfolder3/proc4.rb +3 -0
  156. data/spec/fixtures/dsl/subfolder3/sub/proc5.rb +6 -0
  157. data/spec/fixtures/dsl/subfolder4.eye +6 -0
  158. data/spec/fixtures/dsl/subfolder4/a.rb +2 -0
  159. data/spec/fixtures/dsl/subfolder4/b.rb +1 -0
  160. data/spec/fixtures/dsl/subfolder4/c.rb +1 -0
  161. data/spec/mock_spec.rb +32 -0
  162. data/spec/process/checks/child_checks_spec.rb +79 -0
  163. data/spec/process/checks/cpu_spec.rb +114 -0
  164. data/spec/process/checks/ctime_spec.rb +43 -0
  165. data/spec/process/checks/fsize_spec.rb +22 -0
  166. data/spec/process/checks/http_spec.rb +52 -0
  167. data/spec/process/checks/intergration_spec.rb +32 -0
  168. data/spec/process/checks/memory_spec.rb +113 -0
  169. data/spec/process/child_process_spec.rb +125 -0
  170. data/spec/process/config_spec.rb +75 -0
  171. data/spec/process/controller_spec.rb +173 -0
  172. data/spec/process/monitoring_spec.rb +180 -0
  173. data/spec/process/restart_spec.rb +174 -0
  174. data/spec/process/scheduler_spec.rb +150 -0
  175. data/spec/process/start_spec.rb +261 -0
  176. data/spec/process/states_history_spec.rb +118 -0
  177. data/spec/process/stop_spec.rb +150 -0
  178. data/spec/process/system_spec.rb +100 -0
  179. data/spec/process/triggers/flapping_spec.rb +81 -0
  180. data/spec/process/update_config_spec.rb +63 -0
  181. data/spec/spec_helper.rb +120 -0
  182. data/spec/support/rr_celluloid.rb +36 -0
  183. data/spec/support/scheduler_hack.rb +16 -0
  184. data/spec/support/spec_support.rb +164 -0
  185. data/spec/system_resources_spec.rb +59 -0
  186. data/spec/system_spec.rb +170 -0
  187. data/spec/utils/alive_array_spec.rb +50 -0
  188. data/spec/utils/celluloid_chain_spec.rb +82 -0
  189. data/spec/utils/tail_spec.rb +21 -0
  190. metadata +558 -0
@@ -0,0 +1,56 @@
1
+ #!/usr/bin/env ruby
2
+ $:.unshift File.expand_path(File.join(File.dirname(__FILE__), %w[.. lib]))
3
+ require 'eye/loader'
4
+ require 'optparse'
5
+ require 'eye'
6
+
7
+ options = {:debug => false}
8
+
9
+ OptionParser.new do |opts|
10
+ opts.on( '-h', '--help', 'Display this screen' ) do
11
+ puts opts
12
+ exit
13
+ end
14
+
15
+ opts.on( '-c', '--config CONFIG', 'load with config' ) do |config_path|
16
+ options[:config] = config_path
17
+ end
18
+
19
+ opts.on( '-s', '--socket SOCKET', 'start listen on socket' ) do |socket_path|
20
+ options[:socket_path] = socket_path
21
+ end
22
+
23
+ opts.on( '-l', '--logger LOGGER', 'custom logger' ) do |logger|
24
+ options[:logger] = logger
25
+ end
26
+
27
+ opts.on( '-d', '--debug', 'debug info to logger' ) do
28
+ options[:debug] = true
29
+ end
30
+
31
+ end.parse!
32
+
33
+ Eye::Settings.ensure_eye_dir
34
+
35
+ socket_path = options[:socket_path] || Eye::Settings.socket_path
36
+ server = Eye::Server.new(socket_path)
37
+
38
+ Eye::Logger.log_level = options[:debug] ? Logger::DEBUG : Logger::INFO
39
+ Eye::Logger.link_logger(options[:logger]) if options[:logger]
40
+
41
+ config = options[:config]
42
+ config = File.expand_path(config) if config && !config.empty?
43
+ if config
44
+ res = server.command('load', config)
45
+ exit if res[:error]
46
+ end
47
+
48
+ Eye::Control.set_proc_line
49
+
50
+ server.run!
51
+
52
+ Kernel.trap("INT") do # for foregraund quit
53
+ exit
54
+ end
55
+
56
+ sleep
@@ -0,0 +1,56 @@
1
+ require 'bundler/setup'
2
+ require 'eventmachine'
3
+
4
+ def answer(data)
5
+ case data
6
+ when 'ping' then "pong\n"
7
+ when 'bad' then "what\n"
8
+ when 'timeout' then sleep 5; "ok\n"
9
+ when 'exception' then raise 'haha'
10
+ when 'quit' then EM.stop
11
+ when 'big' then 'a' * 10_000_000
12
+ end
13
+ end
14
+
15
+ class Echo < EM::Connection
16
+ def post_init
17
+ puts "-- someone connected to the echo server!"
18
+ end
19
+
20
+ def receive_data data
21
+ puts "receive #{data.inspect} "
22
+ send_data(answer(data))
23
+ end
24
+
25
+ def unbind
26
+ puts "-- someone disconnected from the echo server!"
27
+ end
28
+ end
29
+
30
+ class EchoObj < EM::Connection
31
+ include EM::P::ObjectProtocol
32
+
33
+ def post_init
34
+ puts "-- someone connected to the echo server!"
35
+ end
36
+
37
+ def receive_object obj # {:command => 'ping'}
38
+ puts "receive #{obj.inspect}"
39
+ send_object(answer(obj[:command]).chop)
40
+ end
41
+
42
+ def unbind
43
+ puts "-- someone disconnected from the echo server!"
44
+ end
45
+ end
46
+
47
+ trap "TERM" do
48
+ EM.stop
49
+ end
50
+
51
+ EM.run do
52
+ EM.start_server '127.0.0.1', 33221, Echo
53
+ EM.start_server '127.0.0.1', 33222, EchoObj
54
+ EM.start_server "/tmp/em_test_sock", nil, Echo
55
+ puts 'started'
56
+ end
@@ -0,0 +1,20 @@
1
+ require 'bundler/setup'
2
+ require 'forking'
3
+
4
+ root = File.expand_path(File.dirname(__FILE__))
5
+
6
+ f = Forking.new(:name => 'forking', :working_dir => root,
7
+ :log_file => "#{root}/forking.log",
8
+ :pid_file => "#{root}/forking.pid", :sync_log => true)
9
+
10
+ 3.times do |i|
11
+ f.spawn(:log_file => "#{root}/child#{i}.log", :sync_log => true) do
12
+ $0 = "forking child"
13
+ loop do
14
+ p "#{Time.now} - #{Time.now.to_f} - #{i} - tick"
15
+ sleep 0.1
16
+ end
17
+ end
18
+ end
19
+
20
+ f.run!
@@ -0,0 +1,144 @@
1
+ #!/usr/bin/env ruby
2
+ require 'optparse'
3
+
4
+ # This hash will hold all of the options
5
+ # parsed from the command-line by
6
+ # OptionParser.
7
+ options = {}
8
+
9
+ optparse = OptionParser.new do|opts|
10
+ # This displays the help screen, all programs are
11
+ # assumed to have this option.
12
+ opts.on( '-h', '--help', 'Display this screen' ) do
13
+ puts opts
14
+ exit
15
+ end
16
+
17
+ opts.on( '-p', '--pid FILE', 'pid_file' ) do |a|
18
+ options[:pid_file] = a
19
+ end
20
+
21
+ opts.on( '-l', '--log FILE', 'log_file' ) do |a|
22
+ options[:log_file] = a
23
+ end
24
+
25
+ opts.on( '-L', '--lock FILE', 'lock_file' ) do |a|
26
+ options[:lock_file] = a
27
+ end
28
+
29
+ opts.on( '-d', '--daemonize', 'Daemonize' ) do
30
+ options[:daemonize] = true
31
+ end
32
+
33
+ opts.on( '-s', '--daemonize_delay DELAY', 'Daemonized time' ) do |d|
34
+ options[:daemonize_delay] = d
35
+ end
36
+
37
+ opts.on( '-r', '--raise', 'Raised execution' ) do
38
+ options[:raise] = true
39
+ end
40
+
41
+ opts.on( '-w', '--watch_file FILE', 'Exit on touched file' ) do |w|
42
+ options[:watch_file] = w
43
+ end
44
+
45
+ opts.on( '-W', '--watch_file_delay DELAY', 'Exit on touched file, after delay' ) do |w|
46
+ options[:watch_file_delay] = w
47
+ end
48
+
49
+ end
50
+
51
+ optparse.parse!
52
+
53
+ module Sample
54
+ def puts(mes = "")
55
+ tm = Time.now
56
+ STDOUT.puts "#{tm.to_s} (#{tm.to_f}) - #{mes}"
57
+ STDOUT.flush
58
+ end
59
+
60
+ def daemonize(pid_file, log_file, daemonize_delay = 0)
61
+ puts "daemonize start #{pid_file}, #{log_file}, #{daemonize_delay}"
62
+
63
+ if daemonize_delay && daemonize_delay.to_f > 0
64
+ puts "daemonize delay start #{daemonize_delay}"
65
+ sleep daemonize_delay.to_f
66
+ puts "daemonize delay end"
67
+ end
68
+
69
+ daemon
70
+ STDOUT.reopen(log_file, "a")
71
+ STDERR.reopen(log_file, "a")
72
+ File.open(pid_file, 'w'){|f| f.write $$.to_s}
73
+
74
+ puts "daemonized"
75
+ end
76
+
77
+ def daemon
78
+ exit if fork # Parent exits, child continues.
79
+ Process.setsid # Become session leader.
80
+ exit if fork # Zap session leader. See [1].
81
+
82
+ STDIN.reopen "/dev/null" # Free file descriptors and
83
+ STDOUT.reopen "/dev/null", "a" # point them somewhere sensible.
84
+ STDERR.reopen '/dev/null', 'a'
85
+ return 0
86
+ end
87
+ end
88
+
89
+ extend Sample
90
+
91
+ if options[:daemonize]
92
+ daemonize(options[:pid_file], options[:log_file], options[:daemonize_delay])
93
+ end
94
+
95
+ puts "Started #{ARGV.inspect}, #{options.inspect}, #{ENV["ENV1"]}"
96
+
97
+ if options[:lock_file]
98
+ if File.exists?(options[:lock_file])
99
+ puts "Lock file exists, exiting"
100
+ exit 1
101
+ else
102
+ File.open(options[:lock_file], 'w'){|f| f.write $$ }
103
+ end
104
+ end
105
+
106
+ if options[:raise]
107
+ puts "Raised"
108
+ File.unlink(options[:lock_file]) if options[:lock_file]
109
+ exit 1
110
+ end
111
+
112
+ trap("USR1") do
113
+ puts "USR1 signal!"
114
+ end
115
+
116
+ trap("USR2") do
117
+ puts "USR2 start memory leak"
118
+ $ar = []
119
+ 300_000.times{|i| $ar << "memory leak #{i}" * 10}
120
+ end
121
+
122
+ loop do
123
+ sleep 0.1
124
+ puts "tick"
125
+
126
+ if options[:watch_file]
127
+ if File.exists?(options[:watch_file])
128
+ puts "watch file finded"
129
+ File.unlink(options[:watch_file])
130
+
131
+ if options[:watch_file_delay]
132
+ puts "watch_file delay start"
133
+ sleep options[:watch_file_delay].to_f
134
+ puts "watch_file delay end"
135
+ end
136
+
137
+ break
138
+ end
139
+ end
140
+ end
141
+
142
+ puts "exit"
143
+ File.unlink(options[:lock_file]) if options[:lock_file]
144
+ exit 0
@@ -0,0 +1,11 @@
1
+ Eye.application "rbenv_example" do
2
+ env 'RBENV_ROOT' => '/usr/local/rbenv', 'PATH' => "/usr/local/rbenv/shims:/usr/local/rbenv/bin:#{ENV['PATH']}"
3
+ working_dir "/projects/some_project"
4
+
5
+ process "some_process" do
6
+ pid_file "some.pid"
7
+ start_command "ruby some.rb"
8
+ daemonize true
9
+ stdall "some.log"
10
+ end
11
+ end
@@ -0,0 +1,65 @@
1
+ Eye.load("./eye/*.rb") # load submodules
2
+ Eye.config do
3
+ logger "/tmp/eye.log" # eye logger
4
+ logger_level Logger::DEBUG
5
+ end
6
+
7
+ Eye.app "test" do
8
+ working_dir File.expand_path(File.join(File.dirname(__FILE__), %w[ processes ]))
9
+ stdall "trash.log" # stdout + stderr
10
+ env "APP_ENV" => "production"
11
+ triggers :flapping, :times => 10, :within => 1.minute
12
+
13
+ group "samples" do
14
+ env "A" => "1" # env merging
15
+ chain :grace => 5.seconds, :action => :restart # restarting with 5s interval, one by one.
16
+
17
+ # eye daemonized process
18
+ process("sample1") do
19
+ pid_file "1.pid" # expanded with working_dir
20
+ start_command "ruby ./sample.rb"
21
+ daemonize true
22
+ stdall "sample1.log"
23
+
24
+ checks :cpu, :below => 30, :times => [3, 5]
25
+ end
26
+
27
+ # self daemonized process
28
+ process("sample2") do
29
+ pid_file "2.pid"
30
+ start_command "ruby ./sample.rb -d --pid 2.pid --log sample2.log"
31
+ stop_command "kill -9 {{PID}}"
32
+
33
+ checks :memory, :below => 300.megabytes, :times => 3
34
+ end
35
+ end
36
+
37
+ # daemon with 3 childs
38
+ process("forking") do
39
+ pid_file "forking.pid"
40
+ start_command "ruby ./forking.rb start"
41
+ stop_command "ruby forking.rb stop"
42
+ stdall "forking.log"
43
+
44
+ start_timeout 5.seconds
45
+ stop_grace 5.seconds
46
+
47
+ monitor_children do
48
+ childs_update_period 5.seconds
49
+
50
+ restart_command "kill -2 {{PID}}"
51
+ checks :memory, :below => 300.megabytes, :times => 3
52
+ end
53
+ end
54
+
55
+ process :event_machine do
56
+ pid_file 'em.pid'
57
+ start_command 'ruby em.rb'
58
+ stdall 'em.log'
59
+ daemonize true
60
+
61
+ checks :socket, :addr => "tcp://127.0.0.1:33221", :send_data => "ping", :expect_data => /pong/,
62
+ :every => 10.seconds, :times => 2, :timeout => 1.second
63
+ end
64
+
65
+ end
@@ -0,0 +1,29 @@
1
+ RUBY = '/usr/local/ruby/1.9.3/bin/ruby' # ruby on the server
2
+ RAILS_ENV = 'production'
3
+
4
+ Eye.application "rails_unicorn" do
5
+ env "RAILS_ENV" => RAILS_ENV, "PATH" => "#{File.dirname(RUBY)}:#{ENV['PATH']}"
6
+ working_dir "/projects/rails_unicorn"
7
+
8
+ process("unicorn") do
9
+ pid_file "tmp/pids/unicorn.pid"
10
+ start_command "#{RUBY} ./bin/unicorn -Dc ./config/unicorn.rb -E #{RAILS_ENV}"
11
+ stop_command "kill -QUIT {{PID}}"
12
+ restart_command "kill -USR2 {{PID}}"
13
+ stdall "log/unicorn.log"
14
+
15
+ checks :cpu, :every => 30, :below => 80, :times => 3
16
+ checks :memory, :every => 30, :below => 150.megabytes, :times => [3,5]
17
+
18
+ start_timeout 30.seconds
19
+ stop_grace 5.seconds
20
+ restart_grace 30.seconds
21
+
22
+ monitor_children do
23
+ stop_command "kill -QUIT {{PID}}"
24
+ checks :cpu, :every => 30, :below => 80, :times => 3
25
+ checks :memory, :every => 30, :below => 150.megabytes, :times => [3,5]
26
+ end
27
+ end
28
+
29
+ end
@@ -0,0 +1,37 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/eye', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = "Konstantin Makarchev"
6
+ gem.email = "kostya27@gmail.com"
7
+
8
+ gem.description = %q{Process monitoring tool. With Bluepill like config syntax. Requires MRI Ruby >= 1.9.2. Uses Celluloid and Celluloid::IO.}
9
+ gem.summary = %q{Process monitoring tool. With Bluepill like config syntax. Requires MRI Ruby >= 1.9.2. Uses Celluloid and Celluloid::IO.}
10
+ gem.homepage = "http://github.com/kostya/eye"
11
+
12
+ gem.files = `git ls-files`.split($\)
13
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
14
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
15
+ gem.name = "eye"
16
+ gem.require_paths = ["lib"]
17
+ gem.version = Eye::VERSION
18
+ gem.license = "MIT"
19
+
20
+ gem.required_ruby_version = '>= 1.9.2' # because of celluloid
21
+ gem.required_rubygems_version = '>= 1.3.6'
22
+
23
+ gem.add_dependency 'celluloid', '~> 0.12.0'
24
+ gem.add_dependency 'celluloid-io', '~> 0.12.0'
25
+ gem.add_dependency 'state_machine'
26
+ gem.add_dependency 'activesupport', '~> 3.2.0'
27
+ gem.add_dependency 'thor'
28
+
29
+ gem.add_development_dependency 'rake'
30
+ gem.add_development_dependency 'rspec'
31
+ gem.add_development_dependency 'simplecov'
32
+ gem.add_development_dependency 'rr'
33
+ gem.add_development_dependency 'ruby-graphviz'
34
+ gem.add_development_dependency 'forking'
35
+ gem.add_development_dependency 'fakeweb'
36
+ gem.add_development_dependency 'eventmachine'
37
+ end
@@ -0,0 +1,25 @@
1
+ module Eye
2
+ VERSION = "0.1.11"
3
+ ABOUT = "Eye v#{VERSION} (c) 2012-2013 @kostya"
4
+
5
+ autoload :Process, 'eye/process'
6
+ autoload :ChildProcess, 'eye/child_process'
7
+ autoload :Server, 'eye/server'
8
+ autoload :Logger, 'eye/logger'
9
+ autoload :System, 'eye/system'
10
+ autoload :SystemResources,'eye/system_resources'
11
+ autoload :Checker, 'eye/checker'
12
+ autoload :Trigger, 'eye/trigger'
13
+ autoload :Group, 'eye/group'
14
+ autoload :Dsl, 'eye/dsl'
15
+ autoload :Application, 'eye/application'
16
+ autoload :Settings, 'eye/settings'
17
+ autoload :Client, 'eye/client'
18
+ autoload :Utils, 'eye/utils'
19
+
20
+ autoload :Controller, 'eye/controller'
21
+ autoload :Control, 'eye/control'
22
+ end
23
+
24
+ ROOT_BINDING = binding
25
+ ENV_LANG = ENV['LANG'] # save original LANG, because ruby somehow rewrite it