I’m trying to build a release of a project I’m working on which has several CSV, JSON and ETS files. There files are used at runtime to import ETS tables and at compile-time to dynamically generate certain modules. However, Distillery does not seem to include them in the release.
At the beginning I had them in a directory inside the Elixir project (alongside lib). I also tried moving the files inside the lib dir (and changing the config accordingly) but the results were the same.
I’ve been reading the docs but don’t find anything about this. There’s the following reference:
code_paths (list of strings);
a list of additional code paths to use when searching
but it does not seem to be related to extra needed files.
New versions of your application will have a slightly different path (as the path includes the version of your app in a release), but the same version will always be the same path, regardless of OTP version, Elixir version, etc.
Thank you. This has tripped me off before. I stored some general app-state-information in a file (because the database would be ridiculously overkill for this), but it turned out that the file was not found after upgrading my release, with the app thus restarting with a blank slate every time after an upgrade.
Yeah my general advice along these lines is to use priv for anything version-specific and/or static data/assets and to rely on something more well-known of your own creation in the filesystem for stateful data, i.e. /var/myapp/. You could also use the var directory created by the release, which you can obtain via the RELEASE_MUTABLE_DIR environment variable exposed to the release (which is used for temporary files like pipes, generated configs, and log files). That said, I would still tend towards using a directory like /var/myapp myself, since you can avoid clutter and manage it’s permissions and so on separately.
defmodule App.Repo do
use Ecto.Repo, otp_app: :app
Dynamically loads the repository url from the
DATABASE_URL environment variable.
def init(_, opts) do
defp put_env(opts, key) do
case load_env(key) do
nil -> opts
val -> Keyword.put(opts, key, val)
defp load_env(:ssl_opts) do
defp load_env(:url), do: System.get_env("DATABASE_URL")
defp load_env(:pool_size), do: String.to_integer(System.get_env("POOL_SIZE"))