Module: ServiceManager

Defined in:
lib/teuton-server/service_manager.rb

Overview

This module start a group of services. One for every client. Every service listen on diferent ports. For example:

  • service 1 listen on port PORT+1, client 1 requests.

  • service 2 listen on port PORT+2, client 2 requests.

  • etc.

Class Method Summary collapse

Class Method Details

.start_services(app_param) ⇒ Exit status

Start one service for every client.

Parameters:

  • app_param (Hash)

    Application configuration params

Returns:

  • (Exit status)

    Exit 0 = OK. Exit 1 = ERROR



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/teuton-server/service_manager.rb', line 14

def start_services(app_param)
  show_starting(app_param)
  services_param = split_app_param_into_services_param(app_param)
  services = []
  begin
   services_param.each do |param|
      services << Thread.new{ Service.new.run(param) }
    end
    services.each { |service| service.join }
  rescue SystemExit, Interrupt
    puts Rainbow("\nteuton-server => Closing...").bright
    exit 0
  end
end