Class: RubyPitaya::Main
- Inherits:
-
Object
- Object
- RubyPitaya::Main
- Defined in:
- lib/rubypitaya/core/main.rb
Instance Method Summary collapse
-
#initialize ⇒ Main
constructor
A new instance of Main.
Constructor Details
#initialize ⇒ Main
Returns a new instance of Main.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/rubypitaya/core/main.rb', line 30 def initialize @setup = Setup.new @environment_name = @setup.fetch('rubypitaya.server.environment', 'development') @is_cheats_enabled = @setup.fetch('rubypitaya.server.cheats', false) @is_development_environment = @environment_name == 'development' @setup.auto_reload if @is_development_environment @log = Logger.new('/proc/self/fd/1') @log.level = Logger::INFO @log.formatter = proc do |severity, datetime, progname, msg| "#{msg}\n" end @application_files_importer = ApplicationFilesImporter.new @application_files_importer.import(@is_cheats_enabled) @application_files_importer.auto_reload if @is_development_environment @server_name = @setup['rubypitaya.server.name'] @service_uuid = SecureRandom.uuid @desktop_name = Socket.gethostname @etcd_prefix = @setup['rubypitaya.etcd.prefix'] @etcd_address = @setup['rubypitaya.etcd.url'] @etcd_lease_seconds = @setup['rubypitaya.etcd.leaseSeconds'] @allow_reconnect = false @etcd_connector = EtcdConnector.new(@service_uuid, @desktop_name, @server_name, @etcd_prefix, @etcd_address, @allow_reconnect, @etcd_lease_seconds, @log) @etcd_connector.connect @nats_address = @setup['rubypitaya.nats.url'] @nats_n_threads = @setup['rubypitaya.server.threads'] @nats_connector = NatsConnector.new(@nats_address, @service_uuid, @server_name, @nats_n_threads, @log) @database_connector = DatabaseConnector.new(@setup, @log) @database_connector.connect @session = Session.new @postman = Postman.new(@nats_connector) @config = Config.new @config.auto_reload if @is_development_environment @services = ServiceHolder.new @handler_router = HandlerRouter.new(@is_cheats_enabled) @initializer_content = InitializerContent.new(@log, @services, @setup, @config, @handler_router.handlers) @initializer_broadcast = InitializerBroadcast.new @initializer_broadcast.run(@initializer_content) connect_services run_http run_server end |