edeliver / edeliver

Deployment for Elixir and Erlang
1.97k stars 186 forks source link

**config_providers** and **overlays** distillery options don't work sometimes after mix edeliver restart command #299

Open aby2503 opened 5 years ago

aby2503 commented 5 years ago

Environment

Verbose output

warning: the VM is running with native name encoding of latin1 which may cause Elixir to malfunction as it expects utf8. Please ensure your locale is set to UTF-8 (which can be verified by running "locale" in your shell)

EDELIVER SERVICE WITH RESTART COMMAND

-----> restarting staging servers

staging node:

  user    : elixir.service
  host    : 10.1.0.125
  path    : /home/service/elixir_ci/service
  response: 

RESTART DONE!

Current behavior

Just run

PRODUCTION_USER="elixir.service" 
PRODUCTION_HOSTS="10.1.0.125" 
DELIVER_TO="/home/elixir.service/elixir_ci/service" 
MIX_ENV=prod 
APP=service 
mix edeliver restart production --debug

In some cases, after restart, release doesn't use updated config params In this case, mongo client(example) doesn't get updated address and tries to connect to default one

[error] Connection to Mongo refused due to %MatchError{term: {:error, :econnrefused}}
%{db_name: "def_db", host: 'localhost', port: 27017} attempt 0

rel/config.exs -

Path.join(["rel", "plugins", "*.exs"])
|> Path.wildcard()
|> Enum.map(&Code.eval_file(&1))

use Mix.Releases.Config,

  default_release: :default,

  default_environment: Mix.env()

environment :dev do
  set(dev_mode: true)
  set(include_erts: false)
  set(cookie: :"2xgsnHjQQ++73s5HQ4rB0Royj8gS1NO+ERF+RDAA/cdqmiXfnMhGwvinndXxK9Bx")
  plugin(Releases.Plugin.LinkConfig)
end

environment :stage do
  set(include_erts: true)
  set(include_src: false)
  set(cookie: :"2xgsnHjQQ++73s5HQ4rB0Royj8gS1NO+BW7+SDD/cdqmiXfnMhGwvinndXxK9Bx")
  set(run_erl_env: "RUN_ERL_LOG_MAXSIZE=50000000 RUN_ERL_LOG_GENERATIONS=50")
  plugin(Releases.Plugin.LinkConfig)
end

environment :prod do
  set(include_erts: true)
  set(include_src: false)
  set(cookie: :"3xgsfLjQQ++73s5HQ4rB0Royj8gS1NO+BW7+SDD/cdqmiXfnMhGwvinndXxJU0x")
  set(run_erl_env: "RUN_ERL_LOG_MAXSIZE=50000000 RUN_ERL_LOG_GENERATIONS=50")

  set(
    config_providers: [
      {Mix.Releases.Config.Providers.Elixir, ["${RELEASE_ROOT_DIR}/etc/config.exs"]}
    ]
  )

  set(overlays: [{:copy, "rel/config/<%= release_name %>/config.exs", "etc/config.exs"}])

  plugin(Releases.Plugin.LinkConfig)
end

release :service do
  set(version: current_version(:service))

  set(
    applications: [
      :service
      :runtime_tools
    ]
  )
end

runtime configuration

use Mix.Config

# SERVICE
config :service, Service.MongoDB,
  host: String.to_charlist(System.get_env("MONGO_HOST")),
  port: String.to_integer(System.get_env("MONGO_PORT")),
  db_name: System.get_env("MONGO_DB")

config :service, Service.NatsHandler,
  host: String.to_charlist(System.get_env("NATS_HOST")),
  port: String.to_integer(System.get_env("NATS_PORT"))

Expected behavior

aby2503 commented 5 years ago

I've attached inotifywait for FINAL sys.config file. It seems, that in some case file merging happens after application start.

12:10:51.145 - Application get env.

  File: 'sys.config'
  Size: 4635            Blocks: 16         IO Block: 4096   regular file
Device: fd01h/64769d    Inode: 279287      Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1013/live.service)   Gid: (  100/   users)
Access: 2018-11-27 12:10:49.168188561 +0000
Modify: 2018-11-27 12:10:50.448179897 +0000
Change: 2018-11-27 12:10:50.448179897 +0000
 Birth: -

  File: 'sys.config'
  Size: 8822            Blocks: 24         IO Block: 4096   regular file
Device: fd01h/64769d    Inode: 279287      Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1013/live.service)   Gid: (  100/   users)
Access: 2018-11-27 12:10:50.580179003 +0000
Modify: 2018-11-27 12:10:51.040175890 +0000
Change: 2018-11-27 12:10:51.040175890 +0000
 Birth: -

 File: 'sys.config'
  Size: 4635            Blocks: 16         IO Block: 4096   regular file
Device: fd01h/64769d    Inode: 279287      Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1013/live.service)   Gid: (  100/   users)
Access: 2018-11-27 12:10:51.204174781 +0000
Modify: 2018-11-27 12:10:51.648171776 +0000
Change: 2018-11-27 12:10:51.648171776 +0000
aby2503 commented 5 years ago

If someone interested, here's full log for sys.config modifications, when application env. reading faile. 4635 - Size for base sys.config 8822 - for merged

File: 'sys.config'
  Size: 94          Blocks: 8          IO Block: 4096   regular file
Device: fd01h/64769d    Inode: 279287      Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1013/live.service)   Gid: (  100/   users)
Access: 2018-11-27 12:10:17.504402847 +0000
Modify: 2018-11-27 12:10:30.436315333 +0000
Change: 2018-11-27 12:10:30.436315333 +0000
 Birth: -
  File: 'sys.config'
  Size: 4635        Blocks: 16         IO Block: 4096   regular file
Device: fd01h/64769d    Inode: 279287      Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1013/live.service)   Gid: (  100/   users)
Access: 2018-11-27 12:10:17.504402847 +0000
Modify: 2018-11-27 12:10:30.440315305 +0000
Change: 2018-11-27 12:10:30.440315305 +0000
 Birth: -
  File: 'sys.config'
  Size: 4635        Blocks: 16         IO Block: 4096   regular file
Device: fd01h/64769d    Inode: 279287      Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1013/live.service)   Gid: (  100/   users)
Access: 2018-11-27 12:10:17.504402847 +0000
Modify: 2018-11-27 12:10:30.440315305 +0000
Change: 2018-11-27 12:10:30.440315305 +0000
 Birth: -
  File: 'sys.config'
  Size: 4635        Blocks: 16         IO Block: 4096   regular file
Device: fd01h/64769d    Inode: 279287      Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1013/live.service)   Gid: (  100/   users)
Access: 2018-11-27 12:10:17.504402847 +0000
Modify: 2018-11-27 12:10:30.440315305 +0000
Change: 2018-11-27 12:10:30.440315305 +0000
 Birth: -
  File: 'sys.config'
  Size: 8822        Blocks: 24         IO Block: 4096   regular file
Device: fd01h/64769d    Inode: 279287      Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1013/live.service)   Gid: (  100/   users)
Access: 2018-11-27 12:10:30.528314709 +0000
Modify: 2018-11-27 12:10:30.736313302 +0000
Change: 2018-11-27 12:10:30.736313302 +0000
 Birth: -
  File: 'sys.config'
  Size: 8822        Blocks: 24         IO Block: 4096   regular file
Device: fd01h/64769d    Inode: 279287      Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1013/live.service)   Gid: (  100/   users)
Access: 2018-11-27 12:10:30.528314709 +0000
Modify: 2018-11-27 12:10:30.736313302 +0000
Change: 2018-11-27 12:10:30.736313302 +0000
 Birth: -
  File: 'sys.config'
  Size: 94          Blocks: 8          IO Block: 4096   regular file
Device: fd01h/64769d    Inode: 279287      Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1013/live.service)   Gid: (  100/   users)
Access: 2018-11-27 12:10:30.836312626 +0000
Modify: 2018-11-27 12:10:31.300309486 +0000
Change: 2018-11-27 12:10:31.300309486 +0000
 Birth: -
  File: 'sys.config'
  Size: 94          Blocks: 8          IO Block: 4096   regular file
Device: fd01h/64769d    Inode: 279287      Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1013/live.service)   Gid: (  100/   users)
Access: 2018-11-27 12:10:30.836312626 +0000
Modify: 2018-11-27 12:10:31.300309486 +0000
Change: 2018-11-27 12:10:31.300309486 +0000
 Birth: -
  File: 'sys.config'
  Size: 4635        Blocks: 16         IO Block: 4096   regular file
Device: fd01h/64769d    Inode: 279287      Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1013/live.service)   Gid: (  100/   users)
Access: 2018-11-27 12:10:30.836312626 +0000
Modify: 2018-11-27 12:10:31.304309458 +0000
Change: 2018-11-27 12:10:31.304309458 +0000
 Birth: -
  File: 'sys.config'
  Size: 4635        Blocks: 16         IO Block: 4096   regular file
Device: fd01h/64769d    Inode: 279287      Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1013/live.service)   Gid: (  100/   users)
Access: 2018-11-27 12:10:30.836312626 +0000
Modify: 2018-11-27 12:10:31.304309458 +0000
Change: 2018-11-27 12:10:31.304309458 +0000
 Birth: -
  File: 'sys.config'
  Size: 8822        Blocks: 24         IO Block: 4096   regular file
Device: fd01h/64769d    Inode: 279287      Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1013/live.service)   Gid: (  100/   users)
Access: 2018-11-27 12:10:31.412308727 +0000
Modify: 2018-11-27 12:10:31.644307158 +0000
Change: 2018-11-27 12:10:31.644307158 +0000
 Birth: -
  File: 'sys.config'
  Size: 8822        Blocks: 24         IO Block: 4096   regular file
Device: fd01h/64769d    Inode: 279287      Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1013/live.service)   Gid: (  100/   users)
Access: 2018-11-27 12:10:31.412308727 +0000
Modify: 2018-11-27 12:10:31.644307158 +0000
Change: 2018-11-27 12:10:31.644307158 +0000
 Birth: -
  File: 'sys.config'
  Size: 4635        Blocks: 16         IO Block: 4096   regular file
Device: fd01h/64769d    Inode: 279287      Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1013/live.service)   Gid: (  100/   users)
Access: 2018-11-27 12:10:31.740306507 +0000
Modify: 2018-11-27 12:10:32.184303503 +0000
Change: 2018-11-27 12:10:32.184303503 +0000
 Birth: -
  File: 'sys.config'
  Size: 4635        Blocks: 16         IO Block: 4096   regular file
Device: fd01h/64769d    Inode: 279287      Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1013/live.service)   Gid: (  100/   users)
Access: 2018-11-27 12:10:31.740306507 +0000
Modify: 2018-11-27 12:10:32.184303503 +0000
Change: 2018-11-27 12:10:32.184303503 +0000
 Birth: -
  File: 'sys.config'
  Size: 4635        Blocks: 16         IO Block: 4096   regular file
Device: fd01h/64769d    Inode: 279287      Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1013/live.service)   Gid: (  100/   users)
Access: 2018-11-27 12:10:31.740306507 +0000
Modify: 2018-11-27 12:10:32.184303503 +0000
Change: 2018-11-27 12:10:32.184303503 +0000
 Birth: -
  File: 'sys.config'
  Size: 4635        Blocks: 16         IO Block: 4096   regular file
Device: fd01h/64769d    Inode: 279287      Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1013/live.service)   Gid: (  100/   users)
Access: 2018-11-27 12:10:31.740306507 +0000
Modify: 2018-11-27 12:10:32.184303503 +0000
Change: 2018-11-27 12:10:32.184303503 +0000
 Birth: -
  File: 'sys.config'
  Size: 8822        Blocks: 24         IO Block: 4096   regular file
Device: fd01h/64769d    Inode: 279287      Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1013/live.service)   Gid: (  100/   users)
Access: 2018-11-27 12:10:32.264302962 +0000
Modify: 2018-11-27 12:10:32.516301256 +0000
Change: 2018-11-27 12:10:32.516301256 +0000
 Birth: -
  File: 'sys.config'
  Size: 8822        Blocks: 24         IO Block: 4096   regular file
Device: fd01h/64769d    Inode: 279287      Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1013/live.service)   Gid: (  100/   users)
Access: 2018-11-27 12:10:32.264302962 +0000
Modify: 2018-11-27 12:10:32.516301256 +0000
Change: 2018-11-27 12:10:32.516301256 +0000
 Birth: -
  File: 'sys.config'
  Size: 94          Blocks: 8          IO Block: 4096   regular file
Device: fd01h/64769d    Inode: 279287      Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1013/live.service)   Gid: (  100/   users)
Access: 2018-11-27 12:10:32.612300607 +0000
Modify: 2018-11-27 12:10:48.700191728 +0000
Change: 2018-11-27 12:10:48.700191728 +0000
 Birth: -
  File: 'sys.config'
  Size: 4635        Blocks: 16         IO Block: 4096   regular file
Device: fd01h/64769d    Inode: 279287      Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1013/live.service)   Gid: (  100/   users)
Access: 2018-11-27 12:10:32.612300607 +0000
Modify: 2018-11-27 12:10:48.704191700 +0000
Change: 2018-11-27 12:10:48.704191700 +0000
 Birth: -
  File: 'sys.config'
  Size: 4635        Blocks: 16         IO Block: 4096   regular file
Device: fd01h/64769d    Inode: 279287      Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1013/live.service)   Gid: (  100/   users)
Access: 2018-11-27 12:10:32.612300607 +0000
Modify: 2018-11-27 12:10:48.704191700 +0000
Change: 2018-11-27 12:10:48.704191700 +0000
 Birth: -
  File: 'sys.config'
  Size: 4635        Blocks: 16         IO Block: 4096   regular file
Device: fd01h/64769d    Inode: 279287      Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1013/live.service)   Gid: (  100/   users)
Access: 2018-11-27 12:10:32.612300607 +0000
Modify: 2018-11-27 12:10:48.704191700 +0000
Change: 2018-11-27 12:10:48.704191700 +0000
 Birth: -
  File: 'sys.config'
  Size: 8822        Blocks: 24         IO Block: 4096   regular file
Device: fd01h/64769d    Inode: 279287      Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1013/live.service)   Gid: (  100/   users)
Access: 2018-11-27 12:10:48.796191078 +0000
Modify: 2018-11-27 12:10:49.012189616 +0000
Change: 2018-11-27 12:10:49.012189616 +0000
 Birth: -
  File: 'sys.config'
  Size: 8822        Blocks: 24         IO Block: 4096   regular file
Device: fd01h/64769d    Inode: 279287      Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1013/live.service)   Gid: (  100/   users)
Access: 2018-11-27 12:10:48.796191078 +0000
Modify: 2018-11-27 12:10:49.012189616 +0000
Change: 2018-11-27 12:10:49.012189616 +0000
 Birth: -
  File: 'sys.config'
  Size: 8822        Blocks: 24         IO Block: 4096   regular file
Device: fd01h/64769d    Inode: 279287      Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1013/live.service)   Gid: (  100/   users)
Access: 2018-11-27 12:10:49.168188561 +0000
Modify: 2018-11-27 12:10:49.636185393 +0000
Change: 2018-11-27 12:10:49.636185393 +0000
 Birth: -
  File: 'sys.config'
  Size: 8822        Blocks: 24         IO Block: 4096   regular file
Device: fd01h/64769d    Inode: 279287      Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1013/live.service)   Gid: (  100/   users)
Access: 2018-11-27 12:10:49.168188561 +0000
Modify: 2018-11-27 12:10:49.636185393 +0000
Change: 2018-11-27 12:10:49.636185393 +0000
 Birth: -
  File: 'sys.config'
  Size: 4635        Blocks: 16         IO Block: 4096   regular file
Device: fd01h/64769d    Inode: 279287      Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1013/live.service)   Gid: (  100/   users)
Access: 2018-11-27 12:10:49.168188561 +0000
Modify: 2018-11-27 12:10:50.448179897 +0000
Change: 2018-11-27 12:10:50.448179897 +0000
 Birth: -
  File: 'sys.config'
  Size: 4635        Blocks: 16         IO Block: 4096   regular file
Device: fd01h/64769d    Inode: 279287      Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1013/live.service)   Gid: (  100/   users)
Access: 2018-11-27 12:10:49.168188561 +0000
Modify: 2018-11-27 12:10:50.448179897 +0000
Change: 2018-11-27 12:10:50.448179897 +0000
 Birth: -
  File: 'sys.config'
  Size: 4635        Blocks: 16         IO Block: 4096   regular file
Device: fd01h/64769d    Inode: 279287      Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1013/live.service)   Gid: (  100/   users)
Access: 2018-11-27 12:10:49.168188561 +0000
Modify: 2018-11-27 12:10:50.448179897 +0000
Change: 2018-11-27 12:10:50.448179897 +0000
 Birth: -
  File: 'sys.config'
  Size: 4635        Blocks: 16         IO Block: 4096   regular file
Device: fd01h/64769d    Inode: 279287      Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1013/live.service)   Gid: (  100/   users)
Access: 2018-11-27 12:10:49.168188561 +0000
Modify: 2018-11-27 12:10:50.448179897 +0000
Change: 2018-11-27 12:10:50.448179897 +0000
 Birth: -
  File: 'sys.config'
  Size: 8822        Blocks: 24         IO Block: 4096   regular file
Device: fd01h/64769d    Inode: 279287      Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1013/live.service)   Gid: (  100/   users)
Access: 2018-11-27 12:10:50.580179003 +0000
Modify: 2018-11-27 12:10:51.040175890 +0000
Change: 2018-11-27 12:10:51.040175890 +0000
 Birth: -
  File: 'sys.config'
  Size: 8822        Blocks: 24         IO Block: 4096   regular file
Device: fd01h/64769d    Inode: 279287      Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1013/live.service)   Gid: (  100/   users)
Access: 2018-11-27 12:10:50.580179003 +0000
Modify: 2018-11-27 12:10:51.040175890 +0000
Change: 2018-11-27 12:10:51.040175890 +0000
 Birth: -
  File: 'sys.config'
  Size: 4635        Blocks: 16         IO Block: 4096   regular file
Device: fd01h/64769d    Inode: 279287      Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1013/live.service)   Gid: (  100/   users)
Access: 2018-11-27 12:10:51.204174781 +0000
Modify: 2018-11-27 12:10:51.648171776 +0000
Change: 2018-11-27 12:10:51.648171776 +0000
 Birth: -
  File: 'sys.config'
  Size: 4635        Blocks: 16         IO Block: 4096   regular file
Device: fd01h/64769d    Inode: 279287      Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1013/live.service)   Gid: (  100/   users)
Access: 2018-11-27 12:10:51.204174781 +0000
Modify: 2018-11-27 12:10:51.648171776 +0000
Change: 2018-11-27 12:10:51.648171776 +0000
 Birth: -
  File: 'sys.config'
  Size: 4635        Blocks: 16         IO Block: 4096   regular file
Device: fd01h/64769d    Inode: 279287      Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1013/live.service)   Gid: (  100/   users)
Access: 2018-11-27 12:10:51.204174781 +0000
Modify: 2018-11-27 12:10:51.648171776 +0000
Change: 2018-11-27 12:10:51.648171776 +0000
 Birth: -
  File: 'sys.config'
  Size: 4635        Blocks: 16         IO Block: 4096   regular file
Device: fd01h/64769d    Inode: 279287      Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1013/live.service)   Gid: (  100/   users)
Access: 2018-11-27 12:10:51.204174781 +0000
Modify: 2018-11-27 12:10:51.648171776 +0000
Change: 2018-11-27 12:10:51.648171776 +0000
 Birth: -
  File: 'sys.config'
  Size: 8822        Blocks: 24         IO Block: 4096   regular file
Device: fd01h/64769d    Inode: 279287      Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1013/live.service)   Gid: (  100/   users)
Access: 2018-11-27 12:10:51.728171234 +0000
Modify: 2018-11-27 12:10:51.936169827 +0000
Change: 2018-11-27 12:10:51.936169827 +0000
 Birth: -
  File: 'sys.config'
  Size: 8822        Blocks: 24         IO Block: 4096   regular file
Device: fd01h/64769d    Inode: 279287      Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1013/live.service)   Gid: (  100/   users)
Access: 2018-11-27 12:10:51.728171234 +0000
Modify: 2018-11-27 12:10:51.936169827 +0000
Change: 2018-11-27 12:10:51.936169827 +0000
 Birth: -
lessless commented 5 years ago

Hi Oleksandr,

Was you able to track down reasons for it?

On Tue, Nov 27, 2018, 13:26 Oleksandr Abelentsev, notifications@github.com wrote:

Reopened #299 https://github.com/edeliver/edeliver/issues/299.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/edeliver/edeliver/issues/299#event-1989427479, or mute the thread https://github.com/notifications/unsubscribe-auth/ABd9zGqnb2dIwA8WyENk_YFiFTbCz9INks5uzS9_gaJpZM4YzjRi .

aby2503 commented 5 years ago

Hi Oleksandr, Was you able to track down reasons for it? On Tue, Nov 27, 2018, 13:26 Oleksandr Abelentsev, @.***> wrote: Reopened #299 <#299>. — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#299 (comment)>, or mute the thread https://github.com/notifications/unsubscribe-auth/ABd9zGqnb2dIwA8WyENk_YFiFTbCz9INks5uzS9_gaJpZM4YzjRi .

Not yet.

aby2503 commented 5 years ago

Hi Oleksandr, Was you able to track down reasons for it? On Tue, Nov 27, 2018, 13:26 Oleksandr Abelentsev, @.***> wrote: Reopened #299 <#299>. — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#299 (comment)>, or mute the thread https://github.com/notifications/unsubscribe-auth/ABd9zGqnb2dIwA8WyENk_YFiFTbCz9INks5uzS9_gaJpZM4YzjRi .

I think I know the reason. I am sure for 99%. That's not a problem of edeliver, but distillery. According to distillery docs https://hexdocs.pm/distillery/config/runtime.html#config-providers, Config Providers invoked during runtime. If we take a look the source code of Elixir.Mix.Releases.Assembler

# Generates .boot script
  defp make_boot_scripts(%Release{name: name, profile: profile} = release) do
    Shell.debug("Generating boot scripts")

    output_dir = profile.output_dir

    with {:ok, boot} <- BootScript.new(release) do
      # This boot script contains all applications, only starting the minimal set
      clean_boot =
        boot
        |> BootScript.start_only([:kernel, :stdlib, :compiler, :elixir])

      # The config boot is like the clean boot, but executes all config providers once started
      providers = release.profile.config_providers

      config_boot =
        clean_boot
        |> BootScript.after_started(:elixir, [
          {:apply, {Mix.Releases.Config.Provider, :init, [providers]}}
        ])

      # Finally, this is the "real" boot script for the app itself
      app_boot =
        boot
        |> BootScript.add_kernel_proc({Mix.Releases.Runtime.Pidfile, :start, []})

      rel_dir = Release.version_path(release)
      bin_dir = Path.join(output_dir, "bin")

      with :ok <- BootScript.write(app_boot),
           :ok <- BootScript.write(app_boot, :start),
           :ok <- BootScript.write(clean_boot, :start_clean),
           :ok <- BootScript.write(clean_boot, :no_dot_erlang),
           :ok <- BootScript.write(config_boot, :config),
           # These two need to be copied to bin/ for ERTS
           :ok <-
             File.cp(
               Path.join(rel_dir, "start_clean.boot"),
               Path.join(bin_dir, "start_clean.boot")
             ),
           :ok <-
             File.cp(
               Path.join(rel_dir, "no_dot_erlang.boot"),
               Path.join(bin_dir, "no_dot_erlang.boot")
             ),
           :ok <- create_RELEASES(output_dir, Path.join(rel_dir, "#{name}.rel")) do
        :ok
      end
    end
  end

After primary start, Mix.Releases.Config.Provider invokes init to process providers. It seems, by some circumstances, this function can be finished after application start

lessless commented 5 years ago

Nice point! Most of the time errors that happens after application starts up has nothing to do with edeliver but it's hard to say because the line between deploying and running is blurred.

On Wed, Nov 28, 2018, 15:39 Oleksandr Abelentsev, notifications@github.com wrote:

Hi Oleksandr, Was you able to track down reasons for it? … <#m4693564782706754870> On Tue, Nov 27, 2018, 13:26 Oleksandr Abelentsev, @.***> wrote: Reopened #299 https://github.com/edeliver/edeliver/issues/299 <#299 https://github.com/edeliver/edeliver/issues/299>. — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#299 (comment) https://github.com/edeliver/edeliver/issues/299#event-1989427479>, or mute the thread https://github.com/notifications/unsubscribe-auth/ABd9zGqnb2dIwA8WyENk_YFiFTbCz9INks5uzS9_gaJpZM4YzjRi .

I think I know the reason. I am sure for 99%. That's not a problem of edeliver, but distillery. According to distillery docs https://hexdocs.pm/distillery/config/runtime.html#config-providers http://url, Config Providers invoked during runtime. If we take a look the source code of Elixir.Mix.Releases.Assembler

Generates .boot script

defp make_boot_scripts(%Release{name: name, profile: profile} = release) do Shell.debug("Generating boot scripts")

output_dir = profile.output_dir

with {:ok, boot} <- BootScript.new(release) do
  # This boot script contains all applications, only starting the minimal set
  clean_boot =
    boot
    |> BootScript.start_only([:kernel, :stdlib, :compiler, :elixir])

  # The config boot is like the clean boot, but executes all config providers once started
  providers = release.profile.config_providers

  config_boot =
    clean_boot
    |> BootScript.after_started(:elixir, [
      {:apply, {Mix.Releases.Config.Provider, :init, [providers]}}
    ])

  # Finally, this is the "real" boot script for the app itself
  app_boot =
    boot
    |> BootScript.add_kernel_proc({Mix.Releases.Runtime.Pidfile, :start, []})

  rel_dir = Release.version_path(release)
  bin_dir = Path.join(output_dir, "bin")

  with :ok <- BootScript.write(app_boot),
       :ok <- BootScript.write(app_boot, :start),
       :ok <- BootScript.write(clean_boot, :start_clean),
       :ok <- BootScript.write(clean_boot, :no_dot_erlang),
       :ok <- BootScript.write(config_boot, :config),
       # These two need to be copied to bin/ for ERTS
       :ok <-
         File.cp(
           Path.join(rel_dir, "start_clean.boot"),
           Path.join(bin_dir, "start_clean.boot")
         ),
       :ok <-
         File.cp(
           Path.join(rel_dir, "no_dot_erlang.boot"),
           Path.join(bin_dir, "no_dot_erlang.boot")
         ),
       :ok <- create_RELEASES(output_dir, Path.join(rel_dir, "#{name}.rel")) do
    :ok
  end
end

end

After primary start, Mix.Releases.Config.Provider invokes init to process providers. It seems, by some circumstances, this function can be finished after application start

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/edeliver/edeliver/issues/299#issuecomment-442469530, or mute the thread https://github.com/notifications/unsubscribe-auth/ABd9zMQ7Rwjj_VPdhJRvJ2x93aIgPwIuks5uzqA2gaJpZM4YzjRi .