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 !



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/xolo/server/app.rb', line 87

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



105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/xolo/server/app.rb', line 105

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



121
122
123
124
125
126
127
128
129
# File 'lib/xolo/server/app.rb', line 121

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)


132
133
134
# File 'lib/xolo/server/app.rb', line 132

def debug?
  Xolo::Server.debug?
end