Class: Daemon::Cluster
Overview
Implements a cluster controlling daemon. The daemon itself itself forks a child process for each port.
Constant Summary collapse
- @@pids =
[]
Class Method Summary collapse
-
.daemon_loop ⇒ Object
The main daemon loop.
-
.fork_server(port) ⇒ Object
Forks a child process with a specific port.
-
.start ⇒ Object
Starts child processes and calls the main loop.
-
.start_servers ⇒ Object
Starts child processes.
-
.stop ⇒ Object
Stops child processes.
-
.stop_servers ⇒ Object
Stops child processes.
Methods inherited from Base
Class Method Details
.daemon_loop ⇒ Object
The main daemon loop. Does nothing for now.
28 29 30 |
# File 'lib/serverside/cluster.rb', line 28 def self.daemon_loop loop {sleep 60} end |
.fork_server(port) ⇒ Object
Forks a child process with a specific port.
8 9 10 11 12 13 |
# File 'lib/serverside/cluster.rb', line 8 def self.fork_server(port) fork do trap('TERM') {exit} server_loop(port) end end |
.start ⇒ Object
Starts child processes and calls the main loop.
33 34 35 36 |
# File 'lib/serverside/cluster.rb', line 33 def self.start start_servers daemon_loop end |
.start_servers ⇒ Object
Starts child processes.
18 19 20 |
# File 'lib/serverside/cluster.rb', line 18 def self.start_servers ports.each {|p| @@pids << fork_server(p)} end |
.stop ⇒ Object
Stops child processes.
39 40 41 |
# File 'lib/serverside/cluster.rb', line 39 def self.stop stop_servers end |