Class: Nand::Cli
Constant Summary
Constants included
from Logging
Logging::LOG_DEBUG, Logging::LOG_ERROR, Logging::LOG_FATAL, Logging::LOG_INFO, Logging::LOG_WARN
Instance Method Summary
collapse
Methods included from Logging
#log, #log_debug!, #logger_formatter, #logger_output_params, #logger_progname
Instance Method Details
#start(target, *argv) ⇒ Object
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/nand/cli.rb', line 30
def start(target, *argv)
opts = restore_options(options)
log_debug! if opts[:debug]
dir = run_dir(opts)
dir.mkpath unless dir.exist?
launcher = find_launcher(target, opts, *argv)
opts[:launcher] = launcher
daemon = Daemon.new(dir, launcher.execname, opts)
print "#{daemon.execname} is Start "
begin
daemon.run
sleep 0
if daemon.running?
puts "Success [#{daemon.pid}]"
end
rescue => e
puts "Failed [#{e.message}]"
log.debug "\t" + e.backtrace.join("\n\t")
exit -1
end
end
|
#status(target = nil) ⇒ Object
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/nand/cli.rb', line 54
def status(target = nil)
ds = if options[:all]
Daemon.all_runnings
else
Daemon.running_in(run_dir(options), target)
end
ds.each do |d|
puts status_message(d.run_dir, d.execname, d.running?, d.pid, d.user)
end
puts status_message(run_dir(options), target, false) if ds.empty? and !target.nil?
end
|
#stop(target = nil) ⇒ Object
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
# File 'lib/nand/cli.rb', line 68
def stop(target = nil)
dir = run_dir(options)
log_debug! if options[:debug]
ds = if options[:all]
Daemon.all_runnings
else
Daemon.running_in(dir, target)
end
ds.each do |d|
pid = d.pid
if d.running?
begin
print "#{d.execname} is "
d.stop and puts "Stopped [#{pid}]"
rescue => e
puts "Failed [#{e.message}]"
log.debug "\t" + e.backtrace.join("\n\t")
end
else
puts "#{d.execname} is Not Running"
end
end
puts status_message(dir, target, false) if !target.nil? and ds.empty?
end
|
94
95
96
|
# File 'lib/nand/cli.rb', line 94
def version
puts File.basename($PROGRAM_NAME) + " " + VERSION
end
|