Class: QEMU::Daemon
- Inherits:
-
Object
- Object
- QEMU::Daemon
- Defined in:
- lib/qemu/daemon.rb
Constant Summary collapse
- @@log_directory =
"log"
- @@run_directory =
"tmp"
Instance Attribute Summary collapse
-
#arguments ⇒ Object
Returns the value of attribute arguments.
-
#command ⇒ Object
Returns the value of attribute command.
-
#env ⇒ Object
Returns the value of attribute env.
-
#log_dir ⇒ Object
Returns the value of attribute log_dir.
-
#name ⇒ Object
Returns the value of attribute name.
-
#run_dir ⇒ Object
Returns the value of attribute run_dir.
Class Method Summary collapse
Instance Method Summary collapse
- #arguments_to(command) ⇒ Object
-
#initialize(attributes = {}) ⇒ Daemon
constructor
A new instance of Daemon.
- #options ⇒ Object
- #options_to(command) ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(attributes = {}) ⇒ Daemon
Returns a new instance of Daemon.
18 19 20 21 |
# File 'lib/qemu/daemon.rb', line 18 def initialize(attributes = {}) attributes = attributes.merge(:name => "qemu", :run_dir => self.class.run_directory, :log_dir => self.class.log_directory) attributes.each { |k,v| send "#{k}=", v } end |
Instance Attribute Details
#arguments ⇒ Object
Returns the value of attribute arguments.
16 17 18 |
# File 'lib/qemu/daemon.rb', line 16 def arguments @arguments end |
#command ⇒ Object
Returns the value of attribute command.
16 17 18 |
# File 'lib/qemu/daemon.rb', line 16 def command @command end |
#env ⇒ Object
Returns the value of attribute env.
16 17 18 |
# File 'lib/qemu/daemon.rb', line 16 def env @env end |
#log_dir ⇒ Object
Returns the value of attribute log_dir.
16 17 18 |
# File 'lib/qemu/daemon.rb', line 16 def log_dir @log_dir end |
#name ⇒ Object
Returns the value of attribute name.
16 17 18 |
# File 'lib/qemu/daemon.rb', line 16 def name @name end |
#run_dir ⇒ Object
Returns the value of attribute run_dir.
16 17 18 |
# File 'lib/qemu/daemon.rb', line 16 def run_dir @run_dir end |
Class Method Details
.log_directory ⇒ Object
7 8 9 |
# File 'lib/qemu/daemon.rb', line 7 def self.log_directory @@log_directory end |
.run_directory ⇒ Object
12 13 14 |
# File 'lib/qemu/daemon.rb', line 12 def self.run_directory @@run_directory end |
Instance Method Details
#arguments_to(command) ⇒ Object
35 36 37 |
# File 'lib/qemu/daemon.rb', line 35 def arguments_to(command) [ command.to_s, "--", *arguments ] end |
#options ⇒ Object
31 32 33 |
# File 'lib/qemu/daemon.rb', line 31 def { :app_name => name, :dir_mode => :normal, :dir => run_dir, :mode => :exec, :log_dir => log_dir, :log_output => true } end |
#options_to(command) ⇒ Object
39 40 41 |
# File 'lib/qemu/daemon.rb', line 39 def (command) .merge :ARGV => arguments_to(command) end |
#start ⇒ Object
43 44 45 46 47 48 |
# File 'lib/qemu/daemon.rb', line 43 def start fork do env.each { |k,v| ENV[k] = v } if env Daemons.run command, (:start) end end |
#stop ⇒ Object
50 51 52 |
# File 'lib/qemu/daemon.rb', line 50 def stop Daemons.run command, (:stop) end |