Class: Peatio::Command::Service::Start::Ranger

Inherits:
Base
  • Object
show all
Defined in:
lib/peatio/command/service.rb

Instance Method Summary collapse

Methods inherited from Base

#say, #sql_client

Instance Method Details

#executeObject

Raises:

  • (ArgumentError)


9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/peatio/command/service.rb', line 9

def execute
  raise ArgumentError, "JWT_PUBLIC_KEY was not specified." if ENV["JWT_PUBLIC_KEY"].to_s.empty?

  key_decoded = Base64.urlsafe_decode64(ENV["JWT_PUBLIC_KEY"])

  jwt_public_key = OpenSSL::PKey.read(key_decoded)
  if jwt_public_key.private?
    raise ArgumentError, "JWT_PUBLIC_KEY was set to private key, however it should be public."
  end

  raise "stats period missing" if stats? && !stats_period

  Prometheus::Client.config.data_store = Prometheus::Client::DataStores::SingleThreaded.new()
  registry = Prometheus::Client.registry

  opts = {
    display_stats: stats?,
    stats_period:  stats_period.to_f,
    metrics_port:  8082,
    registry:      registry
  }
  ::Peatio::Ranger.run!(jwt_public_key, exchange, opts)
end