antikythera v0.4.0 Antikythera.Env View Source
Module to provide helpers to access environment variables defined by antikythera.
Environments and deployments
Antikythera instances and gears may run in the following two modes:
- As a mix project, when invoked by running
iexormixcommand-line tool. - As an OTP release, which is generated by e.g.
antikythera_core.generate_releasetask.
In general there are multiple deployments per antikythera instance. To distingish the target deployment from code, antikythera defines the following environment variables:
- At compile time (for metaprogramming):
ANTIKYTHERA_COMPILE_ENVmust be appropriately set; the value can be retrieved bycompile_env/0. - At runtime:
ANTIKYTHERA_RUNTIME_ENVmust be appropriately set; the value can be retrieved byruntime_env/0.
It is the responsibility of antikythera instance administrators to correctly set these environment variables
when compiling/running antikythera and gears.
Possible values returned by compile_env/0 and runtime_env/0 are:
- names of deployments given by
:deploymentsapplication config :local(running an OTP release at local machine for testing purpose):undefined
As an example, if you set :dev and :prod in :deployments, then you get:
| | Mix.env() at compile-time | Mix.env() at runtime | compile_env(), runtime_env() |
|---------------------------+----------------------------------------+-------------------------+------------------------------|
| $ iex -S mix | :dev (toplevel), :prod (dependencies) | :dev | :undefined |
| $ mix test | :test (toplevel), :prod (dependencies) | :test | :undefined |
| $ mix antikythera_local.* | :prod | (:mix is not available) | :local |
| :dev deployment | :prod | (:mix is not available) | :dev |
| :prod deployment | :prod | (:mix is not available) | :prod |You can use these values to distinguish the current context from your code.
Link to this section Summary
Functions
Timeout (in milli-seconds) for gear actions.
TCP port to listen to for incoming web requests.
Link to this section Types
Specs
t() :: :dev | :prod | :local | :undefined
Link to this section Functions
Specs
antikythera_instance_name() :: atom()
Specs
asset_base_url(Antikythera.GearName.t() | Antikythera.GearNameStr.t()) :: Antikythera.Url.t()
Specs
compile_env() :: t()
Specs
compiling_for_cloud?() :: boolean()
Specs
compiling_for_mix_task?() :: boolean()
Specs
compiling_for_release?() :: boolean()
Specs
default_base_url(Antikythera.GearName.t() | Antikythera.GearNameStr.t(), t()) :: Antikythera.Url.t()
Specs
gear_action_timeout() :: pos_integer()
Timeout (in milli-seconds) for gear actions.
This can be configurable by specifying "GEAR_ACTION_TIMEOUT" environment variable when compiling antikythera.
Defaults to 10000.
Specs
new(any()) :: Croma.Result.t(t())
Specs
Specs
no_listen?() :: boolean()
Specs
port_to_listen() :: non_neg_integer()
TCP port to listen to for incoming web requests.
The port can be specified by "PORT" runtime environment variable.
Defaults to 8081 during mix test, and 8080 otherwise
(thus one can run both iex -S mix and mix test at the same time).
Specs
running_in_cloud?() :: boolean()
Specs
running_on_mix_task?() :: boolean()
Specs
running_with_release?() :: boolean()
Specs
runtime_env() :: t()