Async::ContainerSourceAsyncContainerNotifyLog

class Log

Represents a client that uses a local log file to communicate readiness, status changes, etc.

Definitions

NOTIFY_LOG = "NOTIFY_LOG"

The name of the environment variable which contains the path to the notification socket.

def self.open!(environment = ENV)

Open a notification client attached to the current NOTIFY_LOG = "NOTIFY_LOG" if possible.

Implementation

def self.open!(environment = ENV)
	if path = environment.delete(NOTIFY_LOG)
		self.new(path)
	end
end

def initialize(path)

Initialize the notification client.

Signature

parameter path String

The path to the UNIX socket used for sending messages to the process manager.

Implementation

def initialize(path)
	@path = path
end

attr :path

Signature

attribute String

The path to the UNIX socket used for sending messages to the controller.

def send(**message)

Send the given message.

Signature

parameter message Hash

Implementation

def send(**message)
	data = JSON.dump(message)
	
	File.open(@path, "a") do |file|
		file.puts(data)
	end
end

def error!(text, **message)

Send the specified error. sd_notify requires an errno key, which defaults to -1 to indicate a generic error.

Implementation

def error!(text, **message)
	message[:errno] ||= -1
	
	super
end