Class: Robinhood::Daemon
- Inherits:
-
Object
- Object
- Robinhood::Daemon
- Defined in:
- lib/robinhood/daemon.rb
Overview
This class will start robinhood as a daemon
Defined Under Namespace
Classes: Options
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#log_path ⇒ Object
readonly
Returns the value of attribute log_path.
-
#pids_path ⇒ Object
readonly
Returns the value of attribute pids_path.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Daemon
constructor
Public: Instantiates a new Robinhood::Daemon object.
- #restart ⇒ Object
-
#start ⇒ Object
(also: #run)
Public: Start the daemon.
- #stop ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Daemon
Public: Instantiates a new Robinhood::Daemon object
args - Hash with the different options that can be supplied to the Daemonize object
:config_file - File that will contain the robinhood tasks, by default it will be robinhood.rb
:pids_path - Dir to store de Pidfile for the daemon, by default it will be 'tmp/pids'
:log_path - Dir to store the logs for the daemon, by default it will be 'log'
Returns a new Robinhood::Daemonize
18 19 20 21 22 23 |
# File 'lib/robinhood/daemon.rb', line 18 def initialize(={}) @options = .merge() @file = File.(@options[:config_file]) @pids_path = File.(@options[:pids_path]) @log_path = File.(@options[:log_path]) end |
Instance Attribute Details
#file ⇒ Object (readonly)
Returns the value of attribute file.
8 9 10 |
# File 'lib/robinhood/daemon.rb', line 8 def file @file end |
#log_path ⇒ Object (readonly)
Returns the value of attribute log_path.
8 9 10 |
# File 'lib/robinhood/daemon.rb', line 8 def log_path @log_path end |
#pids_path ⇒ Object (readonly)
Returns the value of attribute pids_path.
8 9 10 |
# File 'lib/robinhood/daemon.rb', line 8 def pids_path @pids_path end |
Instance Method Details
#restart ⇒ Object
45 46 47 48 |
# File 'lib/robinhood/daemon.rb', line 45 def restart stop start end |
#start ⇒ Object Also known as: run
Public: Start the daemon
Returns nothing
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/robinhood/daemon.rb', line 28 def start definition = File.read(file) FileUtils.mkdir_p(log_path) FileUtils.mkdir_p(pids_path) Daemons.run_proc(filename, .merge(ARGV: [@options[:command]])) do instance_eval(definition, @file) Robinhood.run end end |
#stop ⇒ Object
41 42 43 |
# File 'lib/robinhood/daemon.rb', line 41 def stop Daemons.run_proc(filename, .merge(ARGV: ['stop'])) end |