module

PlaceOS::Core

Sequences the acquisition and production of resources

Constants

API_VERSION = "v1"
APP_NAME = "core"
ARCH = {% if flag?(:x86_64) %} "amd64" {% elsif flag?(:aarch64) %} "arm64" {% else %} {% abort("unsupported architechture") %} {% end %}
BUILD_COMMIT = {{ (env("PLACE_COMMIT")) || "DEV" }}
BUILD_HOST = ENV["BUILD_API_HOST"]?
BUILD_PORT = ENV["BUILD_API_PORT"]?
BUILD_TIME = {{ (system("date -u")).chomp.stringify }}
CLUSTER_NODE_TTL = (ENV["CLUSTER_NODE_TTL"]? || "20").to_i

seconds before a node is considered offline should not be divisible by 3

CORE_HOST = !(CORE_HOST_RAW.starts_with?('[')) && (CORE_HOST_RAW.includes?(':')) ? "[#{CORE_HOST_RAW}]" : CORE_HOST_RAW
CORE_HOST_RAW = ENV["CORE_HOST"]? || System.hostname

core self-registers to etcd with this information. In k8s we can grab the Pod information from the environment https://kubernetes.io/docs/tasks/inject-data-application/environment-variable-expose-pod-information/#use-pod-fields-as-values-for-environment-variables

CORE_PORT = (ENV["CORE_PORT"]? || "3000").to_i
DRIVERS = ENV["ENGINE_DRIVERS"]? || (File.join(PlaceOS::Compiler.repository_dir, "drivers"))
Log = ::Log.for(self)
PROCESS_CHECK_PERIOD = (ENV["PLACE_CORE_PROCESS_CHECK_PERIOD"]?.try(&.to_i?) || 80).seconds

Used in ModuleManager

PROCESS_COMMS_TIMEOUT = (ENV["PLACE_CORE_PROCESS_COMMS_TIMEOUT"]?.try(&.to_i?) || 40).seconds
PROD = ENV["SG_ENV"]?.try(&.downcase) == "production"
REDIS_CLIENT = Driver::RedisStorage.shared_redis_client
REDIS_LOCK = Driver::RedisStorage.redis_lock

Minimize the number of connections being made to redis

REDIS_URL = ENV["REDIS_URL"]? || "redis://localhost:6379"
RESPONSE_CODE_HEADER = "Response-Code"
VERSION = "4.20.2"

Class methods

build_host
Source
production?
Source
start_managers
Source
wait_for_resources

Wait for the upstream services to be ready

  • redis
  • postgres
Source

Nested types