Class: Matchd::Control
- Inherits:
-
Object
- Object
- Matchd::Control
- Defined in:
- lib/matchd/control.rb
Overview
Controls the demonizing of a Server
Instance Method Summary collapse
- #daemon_opts ⇒ Object
-
#initialize(options = {}) ⇒ Control
constructor
A new instance of Control.
- #restart(options = {}) ⇒ Object
- #run!(argv, options = {}) ⇒ Object
- #server_opts ⇒ Object
- #start(options = {}) ⇒ Object
- #status ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Control
Returns a new instance of Control.
6 7 8 |
# File 'lib/matchd/control.rb', line 6 def initialize( = {}) @name = .delete(:name, "matchd") end |
Instance Method Details
#daemon_opts ⇒ Object
46 47 48 49 50 51 52 53 54 |
# File 'lib/matchd/control.rb', line 46 def daemon_opts daemon_dir = Matchd::Config.dot_dir { dir_mode: :normal, dir: daemon_dir, log_output: true, log_dir: daemon_dir } end |
#restart(options = {}) ⇒ Object
22 23 24 25 |
# File 'lib/matchd/control.rb', line 22 def restart( = {}) stop start() end |
#run!(argv, options = {}) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/matchd/control.rb', line 28 def run!(argv, = {}) = { ARGV: Array(argv), **, **daemon_opts } Daemons.run_proc(@name, ) do require "matchd/server" Matchd::Server.new(*server_opts).run end end |
#server_opts ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/matchd/control.rb', line 37 def server_opts [ Matchd::Registry.load_file(Matchd::Config.registry_file), Matchd::Config.listen, { resolver: Matchd::Config.resolver } ] end |
#start(options = {}) ⇒ Object
10 11 12 |
# File 'lib/matchd/control.rb', line 10 def start( = {}) run! "start", ontop: .fetch(:ontop, false) end |
#status ⇒ Object
18 19 20 |
# File 'lib/matchd/control.rb', line 18 def status run! "status" end |
#stop ⇒ Object
14 15 16 |
# File 'lib/matchd/control.rb', line 14 def stop run! "stop" end |