Class: Napa::Identity

Inherits:
Object
  • Object
show all
Defined in:
lib/napa/identity.rb

Class Method Summary collapse

Class Method Details

.healthObject



3
4
5
6
7
8
9
10
11
12
# File 'lib/napa/identity.rb', line 3

def self.health
  {
    name: name,
    hostname: hostname,
    revision: revision,
    pid: pid,
    parent_pid: parent_pid,
    platform: platform
  }
end

.hostnameObject



18
19
20
# File 'lib/napa/identity.rb', line 18

def self.hostname
  @hostname ||= `hostname`.strip
end

.nameObject



14
15
16
# File 'lib/napa/identity.rb', line 14

def self.name
  ENV['SERVICE_NAME'] || 'api-service'
end

.parent_pidObject



30
31
32
# File 'lib/napa/identity.rb', line 30

def self.parent_pid
  @ppid ||= Process.ppid
end

.pidObject



26
27
28
# File 'lib/napa/identity.rb', line 26

def self.pid
  @pid ||= Process.pid
end

.platformObject



34
35
36
37
38
39
# File 'lib/napa/identity.rb', line 34

def self.platform
  {
    version: platform_revision,
    name: "Napa"
  }
end

.platform_revisionObject



41
42
43
# File 'lib/napa/identity.rb', line 41

def self.platform_revision
  Napa::VERSION
end

.revisionObject



22
23
24
# File 'lib/napa/identity.rb', line 22

def self.revision
  @revision ||= `git rev-parse HEAD`.strip
end