Module: KicksLiveness::ContainerGeneration Private
- Defined in:
- lib/kicks_liveness/heartbeat.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Identifies an ordinary Linux container incarnation shared by the worker and
exec probes without writing anything to the marks directory. This assumes
the container owns PID 1; shared and host PID namespaces are documented as
unsupported in docs/LIMITATIONS.md.
Class Method Summary collapse
-
.current ⇒ String?
private
Current private-PID Linux container incarnation, or nil when procfs does not expose one.
Class Method Details
.current ⇒ String?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns current private-PID Linux container incarnation, or nil when procfs does not expose one.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/kicks_liveness/heartbeat.rb', line 13 def current mount_namespace = File.readlink('/proc/self/ns/mnt') stat = File.read('/proc/1/stat') closing_parenthesis = stat.rindex(') ') return unless closing_parenthesis # After the command in parentheses, field 3 (`state`) is index 0. Process # start time is field 22, therefore index 19 in this tail. started_at = stat[(closing_parenthesis + 2)..].split[19] return unless started_at && Integer(started_at).positive? "#{mount_namespace}:#{started_at}" rescue StandardError nil end |