Class: Xolo::Server::App

Inherits:
Sinatra::Base
  • Object
show all
Defined in:
lib/xolo/server/app.rb

Overview

The actual server application - a Sinatra/Thin HTTPS server

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.run!(**options, &block) ⇒ Object

Run !



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/xolo/server/app.rb', line 80

def self.run!(**options, &block)
  Xolo::Server.logger.info 'Server App Starting Up'

  setup

  super do |server|
    server.ssl = true
    # verify peer is false so that we don't require client certs
    server.ssl_options = {
      cert_chain_file: Xolo::Server::Configuration::SSL_CERT_FILE.to_s,
      private_key_file: Xolo::Server::Configuration::SSL_KEY_FILE.to_s,
      verify_peer: false
    }
  end # super do
end

.setupObject

Do some setup as we start the server



98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/xolo/server/app.rb', line 98

def self.setup
  Xolo::Server::DATA_DIR.mkpath
  Xolo::Server::Title::TITLES_DIR.mkpath

  setup_ssl

  Xolo::Server.start_time = Time.now

  Xolo::Server::Log.log_rotation_timer_task.execute
  Xolo::Server::Helpers::Maintenance.cleanup_timer_task.execute

  # Disable warnings in logs about known scope bug in Jamf Classic API
  Jamf::Scopable::Scope.do_not_warn_about_policy_scope_bugs
end

.setup_sslObject



114
115
116
117
118
119
120
121
122
# File 'lib/xolo/server/app.rb', line 114

def self.setup_ssl
  Xolo::Server.logger.debug 'Setting up SSL certificates'
  Xolo::Server::Configuration::SSL_DIR.mkpath
  Xolo::Server::Configuration::SSL_DIR.chmod 0o700
  Xolo::Server::Configuration::SSL_CERT_FILE.pix_save Xolo::Server.config.ssl_cert
  Xolo::Server::Configuration::SSL_CERT_FILE.chmod 0o600
  Xolo::Server::Configuration::SSL_KEY_FILE.pix_save Xolo::Server.config.ssl_key
  Xolo::Server::Configuration::SSL_KEY_FILE.chmod 0o600
end

Instance Method Details

#debug?Boolean

Returns:

  • (Boolean)


125
126
127
# File 'lib/xolo/server/app.rb', line 125

def debug?
  Xolo::Server.debug?
end