Class: Daemons::Rails::Controller
- Inherits:
-
Object
- Object
- Daemons::Rails::Controller
- Defined in:
- lib/daemons/rails/controller.rb
Instance Attribute Summary collapse
-
#app_name ⇒ Object
readonly
Returns the value of attribute app_name.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
-
#initialize(controller_path) ⇒ Controller
constructor
A new instance of Controller.
- #run(command, argv = {}) ⇒ Object
- #start(argv = {}) ⇒ Object
- #status ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(controller_path) ⇒ Controller
Returns a new instance of Controller.
6 7 8 9 |
# File 'lib/daemons/rails/controller.rb', line 6 def initialize(controller_path) @path = controller_path @app_name = "#{controller_path.basename.to_s[0...-'_ctl'.length]}.rb" end |
Instance Attribute Details
#app_name ⇒ Object (readonly)
Returns the value of attribute app_name.
4 5 6 |
# File 'lib/daemons/rails/controller.rb', line 4 def app_name @app_name end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
4 5 6 |
# File 'lib/daemons/rails/controller.rb', line 4 def path @path end |
Instance Method Details
#run(command, argv = {}) ⇒ Object
11 12 13 14 15 |
# File 'lib/daemons/rails/controller.rb', line 11 def run(command, argv={}) arguments = '-- ' argv.each {|key,value| arguments += "#{key} #{value} "} `cd "#{Daemons::Rails.configuration.root}" && "#{path}" #{command} #{arguments unless argv.empty?}` end |
#start(argv = {}) ⇒ Object
17 18 19 |
# File 'lib/daemons/rails/controller.rb', line 17 def start(argv={}) run('start',argv) end |
#status ⇒ Object
25 26 27 |
# File 'lib/daemons/rails/controller.rb', line 25 def status run('status').to_s.split("\n").last =~ /: running \[pid \d+\]$/ ? :running : :not_exists end |
#stop ⇒ Object
21 22 23 |
# File 'lib/daemons/rails/controller.rb', line 21 def stop run('stop') end |