105 lines
2.5 KiB
Clojure
105 lines
2.5 KiB
Clojure
(ns Application
|
|
"Elixir Application module — OTP application management.
|
|
|
|
In CljElixir: (Application/get-env :my-app :key), etc.
|
|
Applications are the unit of deployment on the BEAM.")
|
|
|
|
(defn get-env
|
|
"Gets application environment value.
|
|
(Application/get-env :my-app :key) ;=> value or nil
|
|
(Application/get-env :my-app :key :default) ;=> value or :default"
|
|
([app key])
|
|
([app key default]))
|
|
|
|
(defn fetch-env
|
|
"Gets app env. Returns {:ok value} or :error.
|
|
(Application/fetch-env :my-app :key) ;=> {:ok value}"
|
|
[app key])
|
|
|
|
(defn fetch-env!
|
|
"Gets app env. Raises if missing."
|
|
[app key])
|
|
|
|
(defn get-all-env
|
|
"Returns all environment for an application.
|
|
(Application/get-all-env :my-app) ;=> [[:key1 val1] [:key2 val2]]"
|
|
[app])
|
|
|
|
(defn put-env
|
|
"Sets an application environment value.
|
|
(Application/put-env :my-app :key \"value\")"
|
|
([app key value])
|
|
([app key value opts]))
|
|
|
|
(defn put-all-env
|
|
"Sets multiple app env values."
|
|
([app config])
|
|
([app config opts]))
|
|
|
|
(defn delete-env
|
|
"Deletes an application environment value."
|
|
[app key])
|
|
|
|
(defn start
|
|
"Starts an application and its dependencies.
|
|
(Application/start :my-app) ;=> :ok
|
|
(Application/start :my-app :permanent) ;=> with restart type"
|
|
([app])
|
|
([app type]))
|
|
|
|
(defn stop
|
|
"Stops an application.
|
|
(Application/stop :my-app) ;=> :ok"
|
|
[app])
|
|
|
|
(defn ensure-started
|
|
"Ensures an application is started. No-op if already running.
|
|
(Application/ensure-started :logger) ;=> :ok"
|
|
([app])
|
|
([app type]))
|
|
|
|
(defn ensure-all-started
|
|
"Starts an application and all dependencies.
|
|
(Application/ensure-all-started :my-app) ;=> {:ok [:dep1 :dep2 :my-app]}"
|
|
([app])
|
|
([app type]))
|
|
|
|
(defn started-applications
|
|
"Returns a list of all started applications.
|
|
(Application/started-applications) ;=> [[:kernel \"...\" '1.0'] ...]"
|
|
([])
|
|
([timeout]))
|
|
|
|
(defn loaded-applications
|
|
"Returns a list of all loaded applications."
|
|
([])
|
|
([timeout]))
|
|
|
|
(defn which-applications
|
|
"Returns running applications.
|
|
(Application/which-applications) ;=> [...]"
|
|
([])
|
|
([timeout]))
|
|
|
|
(defn spec
|
|
"Returns the application specification.
|
|
(Application/spec :my-app) ;=> full spec
|
|
(Application/spec :my-app :vsn) ;=> version"
|
|
([app])
|
|
([app key]))
|
|
|
|
(defn app-dir
|
|
"Returns the application directory.
|
|
(Application/app-dir :my-app) ;=> \"/path/to/my_app\""
|
|
([app])
|
|
([app path]))
|
|
|
|
(defn compile-env
|
|
"Reads compile-time environment values."
|
|
([app key])
|
|
([app key default]))
|
|
|
|
(defn compile-env!
|
|
"Reads compile-time environment. Raises if missing."
|
|
[app key])
|