evegem 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +14 -0
- data/Gemfile +5 -0
- data/Rakefile +5 -0
- data/autotest/discover.rb +2 -0
- data/bin/eve +18 -0
- data/config.ru +2 -0
- data/config/database.yml.example +16 -0
- data/config/reset_db.rb +10 -0
- data/eve.gemspec +39 -0
- data/lib/eve/application.rb +465 -0
- data/lib/eve/ci.rake +68 -0
- data/lib/eve/event_server.rb +67 -0
- data/lib/eve/file_notifier_server.rb +77 -0
- data/lib/eve/io.rb +25 -0
- data/lib/eve/layout.rb +22 -0
- data/lib/eve/message.rb +181 -0
- data/lib/eve/messenger.rb +138 -0
- data/lib/eve/registry.rb +35 -0
- data/lib/eve/version.rb +3 -0
- data/lib/eve/web_server.rb +22 -0
- data/lib/evegem.rb +23 -0
- data/lib/registry/base_registry.rb +60 -0
- data/lib/registry/charlie_test.rb +18 -0
- data/lib/registry/echo_test.rb +22 -0
- data/lib/registry/empty_registry.rb +11 -0
- data/spec/application_spec.rb +738 -0
- data/spec/base_registry_spec.rb +134 -0
- data/spec/event_server_spec.rb +73 -0
- data/spec/file_notifier_server_spec.rb +89 -0
- data/spec/files/niner_registry.rb +23 -0
- data/spec/layout_spec.rb +28 -0
- data/spec/message_spec.rb +246 -0
- data/spec/messenger_spec.rb +399 -0
- data/spec/spec_helper.rb +35 -0
- metadata +276 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Rakefile
ADDED
data/bin/eve
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'rubygems'
|
3
|
+
require "bundler/setup"
|
4
|
+
require File.dirname(__FILE__) + "/../lib/evegem"
|
5
|
+
|
6
|
+
case ARGV.first
|
7
|
+
when "server"
|
8
|
+
ARGV.shift
|
9
|
+
Eve::EventConnection.run(ARGV)
|
10
|
+
when "watch"
|
11
|
+
ARGV.shift
|
12
|
+
Signal.trap("SIGINT") { exit }
|
13
|
+
Eve::FileNotifierConnection.run(ARGV)
|
14
|
+
else
|
15
|
+
app = Eve::Application.new(:display => :stdio, :system_calls_display => { :filename => "./eve_system_calls.log" })
|
16
|
+
Signal.trap("SIGINT") { app.enqueue_cmd("exit") }
|
17
|
+
app.run(ARGV)
|
18
|
+
end
|
data/config.ru
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
development:
|
2
|
+
adapter: mysql2
|
3
|
+
encoding: utf8
|
4
|
+
reconnect: true
|
5
|
+
database: eve_dev
|
6
|
+
pool: 5
|
7
|
+
username: root
|
8
|
+
socket: "/tmp/mysql.sock"
|
9
|
+
test:
|
10
|
+
adapter: mysql2
|
11
|
+
encoding: utf8
|
12
|
+
reconnect: true
|
13
|
+
database: eve_dev
|
14
|
+
pool: 5
|
15
|
+
username: root
|
16
|
+
socket: "/tmp/mysql.sock"
|
data/config/reset_db.rb
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
|
2
|
+
require "#{File.dirname(__FILE__)}/../spec/db_helper"
|
3
|
+
|
4
|
+
env = Object.const_defined?('Rails') ? Rails.env : "test"
|
5
|
+
db = YAML::load(File.open("#{File.dirname(__FILE__)}/database.yml"))[env]
|
6
|
+
|
7
|
+
path = ENV['SIN_DOC_PATH'] || "#{File.dirname(__FILE__)}/../../sin_doc"
|
8
|
+
execute_sql(db,"drop database `#{db['database']}`;",false)
|
9
|
+
execute_sql(db,"create database `#{db['database']}`;",false)
|
10
|
+
execute_sql_file(db,"#{path}/CDB_EXPORT_For_Test_Suite.sql",true)
|
data/eve.gemspec
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "eve/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "evegem"
|
7
|
+
s.version = Eve::VERSION
|
8
|
+
s.authors = ["Andrew Forward"]
|
9
|
+
s.email = ["andrew.forward@cenx.com"]
|
10
|
+
s.homepage = ""
|
11
|
+
s.summary = %q{A DSL for managing OSS Data Entry}
|
12
|
+
s.description = %q{A DSL for managing OSS Data Entry}
|
13
|
+
|
14
|
+
s.files = `git ls-files`.split("\n")
|
15
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
17
|
+
s.executables = [ 'eve' ]
|
18
|
+
s.require_paths = ["lib"]
|
19
|
+
|
20
|
+
s.add_dependency('utest','>=0.0.3')
|
21
|
+
s.add_dependency('watchme','>=0.0.1')
|
22
|
+
s.add_dependency('awesome_print')
|
23
|
+
s.add_dependency('rake','0.9.2')
|
24
|
+
s.add_dependency('rails','>=3.2.1')
|
25
|
+
s.add_dependency('mysql2','0.3.11')
|
26
|
+
s.add_dependency('rack','1.4.1')
|
27
|
+
s.add_dependency('eventmachine','0.12.10')
|
28
|
+
s.add_dependency('net-ssh','2.3.0')
|
29
|
+
s.add_dependency('redis','2.2.0')
|
30
|
+
|
31
|
+
s.add_development_dependency('rspec')
|
32
|
+
s.add_development_dependency('autotest')
|
33
|
+
s.add_development_dependency('autotest-fsevent') if RUBY_PLATFORM =~ /darwin/i
|
34
|
+
s.add_development_dependency('ZenTest')
|
35
|
+
s.add_development_dependency('rb-fsevent') if RUBY_PLATFORM =~ /darwin/i
|
36
|
+
s.add_development_dependency('geminabox')
|
37
|
+
s.add_development_dependency('simplecov')
|
38
|
+
|
39
|
+
end
|
@@ -0,0 +1,465 @@
|
|
1
|
+
module Eve
|
2
|
+
|
3
|
+
class Application
|
4
|
+
|
5
|
+
cattr_accessor :cmd_data
|
6
|
+
attr_accessor :id, :console, :system_calls, :message, :redis, :poll, :poll_cmds, :cmds, :big_t, :mode, :server, :port
|
7
|
+
|
8
|
+
@@cmd_data = {
|
9
|
+
"version" => [],
|
10
|
+
"help" => [],
|
11
|
+
"appid" => [],
|
12
|
+
"shell" => [],
|
13
|
+
"poll" => [ "set", "add", "rm" ],
|
14
|
+
"event" => [],
|
15
|
+
"remote" => [],
|
16
|
+
"interrupt" => [],
|
17
|
+
"register" => [ "add", "rm", "reload", "add-path", "rm-path", "path" ],
|
18
|
+
"print" => [],
|
19
|
+
"exit" => [],
|
20
|
+
}
|
21
|
+
|
22
|
+
def initialize(data = {})
|
23
|
+
@redis = data[:redis] || Redis.new
|
24
|
+
@console = Messenger.new( :display => data[:display] )
|
25
|
+
@system_calls = Messenger.new( :display => data[:system_calls_display] || data[:display] )
|
26
|
+
|
27
|
+
@message = Message.new(self)
|
28
|
+
@poll = 5*60
|
29
|
+
@poll_cmds = []
|
30
|
+
@cmds = []
|
31
|
+
@big_t = data[:big_t] || "1month"
|
32
|
+
@mode = data[:mode] || :queue
|
33
|
+
@server = data[:server] || "0.0.0.0"
|
34
|
+
@port = data[:port] || "4848"
|
35
|
+
@running = false
|
36
|
+
end
|
37
|
+
|
38
|
+
def reset
|
39
|
+
@cmds = []
|
40
|
+
@console.reset
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.extract_arg(name,args,default = [],has_data = true)
|
44
|
+
is_multi = default.kind_of?(Array)
|
45
|
+
index = args.index(name)
|
46
|
+
return default if index.nil?
|
47
|
+
return is_multi ? [true] : true unless has_data
|
48
|
+
|
49
|
+
results = []
|
50
|
+
args.each_with_index.collect { |d,i| d == name ? i : nil }.compact.each do |index|
|
51
|
+
val = ""
|
52
|
+
args[index+1..-1].each do |data|
|
53
|
+
break if data.start_with?("--")
|
54
|
+
val += " #{data}"
|
55
|
+
end
|
56
|
+
results << val.strip
|
57
|
+
end
|
58
|
+
is_multi ? results : results.first
|
59
|
+
end
|
60
|
+
|
61
|
+
def self.methodize(input)
|
62
|
+
input.gsub(/-/,"_")
|
63
|
+
end
|
64
|
+
|
65
|
+
def default_result
|
66
|
+
{ :data => nil, :status => :continue, :track_cmd => true }
|
67
|
+
end
|
68
|
+
|
69
|
+
#------------
|
70
|
+
# EVENT MACHINE
|
71
|
+
#------------
|
72
|
+
|
73
|
+
def post_init
|
74
|
+
@message.print_server_init
|
75
|
+
end
|
76
|
+
|
77
|
+
def receive_data(data)
|
78
|
+
cmd(data,true,true)
|
79
|
+
end
|
80
|
+
|
81
|
+
#------------
|
82
|
+
# MAIN DRIVER - RUN / CMD
|
83
|
+
#------------
|
84
|
+
|
85
|
+
def run(args = [])
|
86
|
+
@running = true
|
87
|
+
scripts = ["version"] + handle_args(args)
|
88
|
+
loop do
|
89
|
+
scripts.each do |script|
|
90
|
+
status = cmd(script,true,true)[:status]
|
91
|
+
status = cmd("exit") if status == :should_exit
|
92
|
+
return if status == :exited
|
93
|
+
end
|
94
|
+
scripts = next_cmds
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def call_interrupt(result,appid,display_messages)
|
99
|
+
@redis.set(lookup_id("mode",appid),"shell")
|
100
|
+
@message.print_app_interrupted(appid) if display_messages
|
101
|
+
result
|
102
|
+
end
|
103
|
+
|
104
|
+
def cmd(raw,display_messages = true,external_cmd = false)
|
105
|
+
result = default_result
|
106
|
+
raw = "remote #{raw}" if @mode == :event
|
107
|
+
begin
|
108
|
+
action, data = action_and_input(raw)
|
109
|
+
|
110
|
+
num_times_processed = 0
|
111
|
+
if @@cmd_data.keys.include?(action)
|
112
|
+
inner_action, inner_data = action_and_input(data)
|
113
|
+
if @@cmd_data[action].include?(inner_action)
|
114
|
+
result = send(Application.methodize("call_#{action}_#{inner_action}"), result, inner_data, display_messages)
|
115
|
+
else
|
116
|
+
result = send(Application.methodize("call_#{action}"), result, data, display_messages)
|
117
|
+
end
|
118
|
+
num_times_processed += 1
|
119
|
+
end
|
120
|
+
num_times_processed, result = delegate(num_times_processed,result,raw,display_messages) unless @id.nil?
|
121
|
+
|
122
|
+
if num_times_processed == 0 && !action.empty?
|
123
|
+
@message.print_unknown_cmd(raw)
|
124
|
+
end
|
125
|
+
|
126
|
+
@cmds << raw if external_cmd && result[:track_cmd]
|
127
|
+
rescue Exception => ex
|
128
|
+
@message.print_cmd_error(raw,ex)
|
129
|
+
end
|
130
|
+
result
|
131
|
+
end
|
132
|
+
|
133
|
+
#------------
|
134
|
+
# CALLER METHODS
|
135
|
+
#------------
|
136
|
+
|
137
|
+
def call_register(result,data,display_messages)
|
138
|
+
result[:data] = {}
|
139
|
+
@redis.smembers(lookup_id("registers")).collect do |classname|
|
140
|
+
result[:data][classname] = @redis.smembers(lookup_id("register.#{classname}.files"))
|
141
|
+
end
|
142
|
+
@message.print_registry(result[:data])
|
143
|
+
result
|
144
|
+
end
|
145
|
+
|
146
|
+
def call_register_add(result,data,display_messages)
|
147
|
+
parts = data.split
|
148
|
+
classname = parts[0]
|
149
|
+
filename = parts[1]
|
150
|
+
if filename.nil? || filename == ""
|
151
|
+
(cmd("register path",false)[:data]).each do |path|
|
152
|
+
filename = "#{path}/#{classname.split("::").last.underscore}.rb"
|
153
|
+
next unless p?(filename)
|
154
|
+
filename = p(filename)
|
155
|
+
break
|
156
|
+
end
|
157
|
+
end
|
158
|
+
load filename
|
159
|
+
@redis.sadd(lookup_id("registers"),classname)
|
160
|
+
@redis.sadd(lookup_id("register.#{classname}.files"),filename)
|
161
|
+
result[:data] = true
|
162
|
+
result
|
163
|
+
end
|
164
|
+
|
165
|
+
def call_register_add_path(result,path,display_messages)
|
166
|
+
if p?(path)
|
167
|
+
result[:data] = @redis.sadd(lookup_id("register.paths"),p(path))
|
168
|
+
else
|
169
|
+
result[:data] = false
|
170
|
+
end
|
171
|
+
result
|
172
|
+
end
|
173
|
+
|
174
|
+
def call_register_rm_path(result,path,display_messages)
|
175
|
+
normalized_path = p?(path) ? p(path) : path
|
176
|
+
result[:data] = @redis.srem(lookup_id("register.paths"),normalized_path)
|
177
|
+
result
|
178
|
+
end
|
179
|
+
|
180
|
+
def call_register_path(result,path,display_messages)
|
181
|
+
result[:data] = [ p("#{File.dirname(__FILE__)}/../registry") ] + @redis.smembers(lookup_id("register.paths"))
|
182
|
+
@message.print_registry_path(result[:data]) if display_messages
|
183
|
+
result
|
184
|
+
end
|
185
|
+
|
186
|
+
def call_register_rm(result,classname,display_messages)
|
187
|
+
result[:data] = @redis.srem(lookup_id("registers"),classname)
|
188
|
+
@redis.del(lookup_id("register.#{classname}.files"))
|
189
|
+
result
|
190
|
+
end
|
191
|
+
|
192
|
+
def call_register_reload(result,data,display_messages)
|
193
|
+
@redis.smembers(lookup_id("registers")).each do |classname|
|
194
|
+
@redis.smembers(lookup_id("register.#{classname}.files")).each do |filename|
|
195
|
+
load filename
|
196
|
+
end
|
197
|
+
end
|
198
|
+
@message.print_registry_reloaded if display_messages
|
199
|
+
result[:data] = true
|
200
|
+
result
|
201
|
+
end
|
202
|
+
|
203
|
+
def call_appid(result,appid,display_messages)
|
204
|
+
@id = appid == "" || appid.nil? ? $$.to_s : appid
|
205
|
+
|
206
|
+
is_existing = @redis.sismember("Eve.ApplicationIds",@id)
|
207
|
+
@redis.sadd("Eve.ApplicationIds",@id)
|
208
|
+
result[:data] = @id
|
209
|
+
@message.print_appid(@id)
|
210
|
+
cmd("register reload",display_messages) if is_existing
|
211
|
+
result
|
212
|
+
end
|
213
|
+
|
214
|
+
def call_version(result,data,display_messages)
|
215
|
+
result[:data] = Eve::VERSION
|
216
|
+
@message.print_version(@id) if display_messages
|
217
|
+
result
|
218
|
+
end
|
219
|
+
|
220
|
+
def call_help(result,data,display_messages)
|
221
|
+
|
222
|
+
if data.nil? || data == ""
|
223
|
+
result[:data] = @@cmd_data.dup
|
224
|
+
@redis.smembers(lookup_id("registers")).each do |name|
|
225
|
+
clazz = reg(name)
|
226
|
+
if clazz.nil?
|
227
|
+
@redis.srem(lookup_id("registers"),name)
|
228
|
+
else
|
229
|
+
result[:data].merge!(clazz.available)
|
230
|
+
end
|
231
|
+
end
|
232
|
+
else
|
233
|
+
clazz = reg(data)
|
234
|
+
if clazz.nil?
|
235
|
+
@message.print_unknown_handler(data) if display_messages
|
236
|
+
result[:data] = {}
|
237
|
+
else
|
238
|
+
result[:data] = clazz.available
|
239
|
+
end
|
240
|
+
end
|
241
|
+
@message.print_help(result[:data],data) if display_messages && !result[:data].empty?
|
242
|
+
result
|
243
|
+
end
|
244
|
+
|
245
|
+
def call_print(result,msg,display_messages)
|
246
|
+
result[:data] = msg
|
247
|
+
@console.print("#{msg}\n") if display_messages
|
248
|
+
result
|
249
|
+
end
|
250
|
+
|
251
|
+
def call_exit(result,data,display_messages)
|
252
|
+
result[:status] = :exited
|
253
|
+
@message.print_exit if display_messages
|
254
|
+
result
|
255
|
+
end
|
256
|
+
|
257
|
+
def call_poll(result,duration,display_messages)
|
258
|
+
result[:data] = @poll_cmds
|
259
|
+
@message.print_poll_details(@poll,result[:data])
|
260
|
+
result
|
261
|
+
end
|
262
|
+
|
263
|
+
def call_poll_add(result,cmd,display_messages)
|
264
|
+
@poll_cmds << cmd
|
265
|
+
result
|
266
|
+
end
|
267
|
+
|
268
|
+
def call_poll_rm(result,index,display_messages)
|
269
|
+
result[:data] = []
|
270
|
+
if index.to_i.to_s == index
|
271
|
+
@poll_cmds.delete_at(index.to_i)
|
272
|
+
else
|
273
|
+
@poll_cmds.delete(index)
|
274
|
+
end
|
275
|
+
result
|
276
|
+
end
|
277
|
+
|
278
|
+
def call_poll_set(result,duration,display_messages)
|
279
|
+
@mode = :poll
|
280
|
+
in_secs = WatchMe::Timer.to_seconds(duration)
|
281
|
+
result[:data] = in_secs
|
282
|
+
@poll = in_secs
|
283
|
+
@message.print_poll_mode(@id,in_secs) if display_messages
|
284
|
+
result
|
285
|
+
end
|
286
|
+
|
287
|
+
def call_shell(result,data,display_messages)
|
288
|
+
@mode = :shell
|
289
|
+
result[:data] = @mode
|
290
|
+
@message.print_shell_mode if display_messages
|
291
|
+
result
|
292
|
+
end
|
293
|
+
|
294
|
+
def call_event(result, data, display_messages)
|
295
|
+
@mode = :event
|
296
|
+
@server,@port = data.split(":")
|
297
|
+
@server ||= "0.0.0.0"
|
298
|
+
@port ||= "4848"
|
299
|
+
result[:data] = { :server => @server, :port => @port }
|
300
|
+
@message.print_event_mode("#{@server}:#{@port}") if display_messages
|
301
|
+
result
|
302
|
+
end
|
303
|
+
|
304
|
+
def call_remote(result, cmd, display_messages)
|
305
|
+
should_exit = false
|
306
|
+
begin
|
307
|
+
@telnet ||= Net::Telnet::new("Host" => @server, "Port" => @port, "Timeout" => 10, "Telnetmode" => false) # debugging "Output_log"=>"application_telnet.log"
|
308
|
+
if cmd == "exit"
|
309
|
+
should_exit = true
|
310
|
+
@telnet.close
|
311
|
+
else
|
312
|
+
result[:data] = @telnet.cmd(cmd) do |data|
|
313
|
+
data.sub!(/[^\n]*> $/,"") unless @running
|
314
|
+
@console.print data
|
315
|
+
end
|
316
|
+
end
|
317
|
+
rescue Exception => ex
|
318
|
+
@message.print_error("Telnet session failed", ex)
|
319
|
+
should_exit = true
|
320
|
+
end
|
321
|
+
|
322
|
+
if should_exit
|
323
|
+
@mode = :shell
|
324
|
+
cmd("exit",display_messages)
|
325
|
+
result[:status] = :exited
|
326
|
+
end
|
327
|
+
|
328
|
+
result
|
329
|
+
end
|
330
|
+
|
331
|
+
#------------
|
332
|
+
# HELPER METHODS
|
333
|
+
#------------
|
334
|
+
|
335
|
+
def reg(classname)
|
336
|
+
begin
|
337
|
+
all_names = classname.split("::")
|
338
|
+
all_names.size == 1 ? Object::const_get(classname) : eval(all_names[0...-1].join("::")).const_get(all_names.last)
|
339
|
+
rescue
|
340
|
+
nil
|
341
|
+
end
|
342
|
+
end
|
343
|
+
|
344
|
+
def delegate(num_times_processed,result,cmd,display_messages)
|
345
|
+
all_results = num_times_processed > 0 ? [ result.dup ] : []
|
346
|
+
@redis.smembers(lookup_id("registers")).each do |classname|
|
347
|
+
all_names = classname.split("::")
|
348
|
+
clazz = reg(classname)
|
349
|
+
next unless clazz.handle?(cmd)
|
350
|
+
all_results << clazz.handle(self,cmd,display_messages)
|
351
|
+
num_times_processed += 1
|
352
|
+
end
|
353
|
+
result[:data] = nil if num_times_processed == 0
|
354
|
+
result[:data] = all_results[0][:data] if num_times_processed == 1
|
355
|
+
result[:data] = all_results if num_times_processed > 1
|
356
|
+
[ num_times_processed, result ]
|
357
|
+
end
|
358
|
+
|
359
|
+
def enqueue_cmd(raw)
|
360
|
+
@redis.rpush(lookup_id("next_cmds"),raw)
|
361
|
+
end
|
362
|
+
|
363
|
+
def next_cmds(scripts = [])
|
364
|
+
case(@mode)
|
365
|
+
when :event
|
366
|
+
scripts << user_input
|
367
|
+
when :poll
|
368
|
+
scripts += @poll_cmds
|
369
|
+
scripts << "sleep #{@poll}"
|
370
|
+
when :shell
|
371
|
+
scripts << user_input
|
372
|
+
when :queue
|
373
|
+
the_cmd = @redis.lpop(lookup_id("next_cmds")) || "exit"
|
374
|
+
scripts << the_cmd
|
375
|
+
end
|
376
|
+
scripts
|
377
|
+
end
|
378
|
+
|
379
|
+
def handle_args(args)
|
380
|
+
scripts = []
|
381
|
+
|
382
|
+
is_event = false
|
383
|
+
Application.extract_arg("--event",args).each do |event|
|
384
|
+
is_event = true
|
385
|
+
scripts << "event #{event}"
|
386
|
+
end
|
387
|
+
|
388
|
+
index = args.index("--interrupt")
|
389
|
+
unless index.nil?
|
390
|
+
scripts << "interrupt #{args[index+1]}"
|
391
|
+
scripts << "exit"
|
392
|
+
return scripts
|
393
|
+
end
|
394
|
+
|
395
|
+
index = args.index("--id")
|
396
|
+
if !index.nil?
|
397
|
+
scripts << "appid #{args[index + 1]}"
|
398
|
+
elsif @id.nil? && !is_event
|
399
|
+
scripts << "appid"
|
400
|
+
end
|
401
|
+
|
402
|
+
Application.extract_arg("--register",args).each { |register| scripts << "register add #{register}" }
|
403
|
+
|
404
|
+
unless is_event
|
405
|
+
Application.extract_arg("--poll",args).each { |poll| scripts << "poll #{poll}" }
|
406
|
+
scripts << "shell" unless Application.extract_arg("--shell",args,nil,false).nil?
|
407
|
+
end
|
408
|
+
|
409
|
+
Application.extract_arg("--run",args).each do |cmd|
|
410
|
+
scripts << cmd
|
411
|
+
end
|
412
|
+
|
413
|
+
scripts
|
414
|
+
end
|
415
|
+
|
416
|
+
def self.ids(redis = Redis.new)
|
417
|
+
redis.smembers("Eve.ApplicationIds")
|
418
|
+
end
|
419
|
+
|
420
|
+
def self.alive?(id)
|
421
|
+
return false if id == "" || id.nil?
|
422
|
+
begin
|
423
|
+
Process.kill 0, id.to_i
|
424
|
+
true
|
425
|
+
rescue Exception => ex
|
426
|
+
false
|
427
|
+
end
|
428
|
+
end
|
429
|
+
|
430
|
+
def lookup_id(sub_id, appid = nil)
|
431
|
+
raise "Application ID not set yet" if appid.nil? && @id.nil?
|
432
|
+
appid ||= @id
|
433
|
+
"Eve.#{appid}.#{sub_id}"
|
434
|
+
end
|
435
|
+
|
436
|
+
def history
|
437
|
+
@console.history
|
438
|
+
end
|
439
|
+
|
440
|
+
def system_call(input)
|
441
|
+
@message.print_system_call(input)
|
442
|
+
`#{input}`
|
443
|
+
end
|
444
|
+
|
445
|
+
def user_input
|
446
|
+
@console.print "> " unless @mode == :event
|
447
|
+
STDOUT.flush
|
448
|
+
STDIN.gets.chomp
|
449
|
+
end
|
450
|
+
|
451
|
+
|
452
|
+
private
|
453
|
+
|
454
|
+
def action_and_input(raw)
|
455
|
+
return [ "", nil ] if raw.nil?
|
456
|
+
action = raw.split.shift
|
457
|
+
return [ "", nil ] if (action.nil? || action.starts_with?("#"))
|
458
|
+
data = raw[(action.size)..-1].strip
|
459
|
+
[ action, data ]
|
460
|
+
end
|
461
|
+
|
462
|
+
|
463
|
+
end
|
464
|
+
|
465
|
+
end
|