Class: Pfab::Templates::LongRunningProcess

Inherits:
Base
  • Object
show all
Defined in:
lib/pfab/templates/long_running_process.rb

Direct Known Subclasses

Daemon, Web

Instance Method Summary collapse

Methods inherited from Base

#app_vars, #application_type, #container_ports, #cpu, #deploy_id, #deploy_unique_id, #env_from, #env_vars, #get, #get_command, #get_namespace, #image_name, #initialize, #load_env_vars, #load_secrets, #memory, #resources

Constructor Details

This class inherits a constructor from Pfab::Templates::Base

Instance Method Details

#default_probeObject



7
8
9
10
11
12
13
14
15
16
# File 'lib/pfab/templates/long_running_process.rb', line 7

def default_probe
  {
    httpGet: {
      path: get("health_check_path") || "/",
      port: get("port"),
    },
    initialDelaySeconds: 15,
    timeoutSeconds: 3
  }
end

#livenessProbeObject



18
19
20
# File 'lib/pfab/templates/long_running_process.rb', line 18

def livenessProbe
  get("livenessProbe") || default_probe
end

#probesObject



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/pfab/templates/long_running_process.rb', line 30

def probes

  if application_type == "web" || get("probesEnabled")
    return {
      livenessProbe: livenessProbe,
      readinessProbe: readinessProbe,
      startupProbe: startupProbe,
    }
  end
  puts "probes are disabled, set `probesEnabled: true` to enable"
  return {

  }

end

#readinessProbeObject



22
23
24
# File 'lib/pfab/templates/long_running_process.rb', line 22

def readinessProbe
  get("readinessProbe") || default_probe
end

#rolling_update_strategyObject



47
48
49
50
51
52
53
54
55
# File 'lib/pfab/templates/long_running_process.rb', line 47

def rolling_update_strategy
  {
    type: "RollingUpdate",
    rollingUpdate: {
      maxSurge: get("maxSurge") || 1,
      maxUnavailable: get("maxUnavailable") || 0,
    }
  }
end

#startupProbeObject



26
27
28
# File 'lib/pfab/templates/long_running_process.rb', line 26

def startupProbe
  get("startupProbe") || default_probe
end