bitwalker / distillery

Simplify deployments in Elixir with OTP releases!
MIT License
2.96k stars 396 forks source link

Windows: start_erl.data error because var directory does not exist before first run of new release #705

Open hlampert opened 4 years ago

hlampert commented 4 years ago

Steps to reproduce

  1. Copy brand new release directory to new system
  2. Run the release tasks script first time. Example batch file command that runs this script:
    > %da_siteprocessing_umbrella_root%\bin\da_siteprocessing_umbrella get-tag-history location:%location% tagfile:%1 outputfile:%output% sortorder:%sortorder%

Verbose Logs

copy-item : Could not find a part of the path
'C:\Users\labuser\Documents\ASDDataLake\da_siteprocessing_umbrella\var\start_erl.data'.
At C:\Users\labuser\Documents\ASDDataLake\da_siteprocessing_umbrella\releases\0.2.4\da_siteprocessing_umbrella.ps1:92
char:5
+     copy-item -Path (join-path $releases_dir "start_erl.data") -Desti ...
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Copy-Item], DirectoryNotFoundException
    + FullyQualifiedErrorId : System.IO.DirectoryNotFoundException,Microsoft.PowerShell.Commands.CopyItemCommand

Description of issue

Before the first run of a brand new release, the top level var directory does not exist. the release tasks PowerShell script attempts to copy start_erl.data to this directory and fails, but keeps running. Somewhere after this the var directory is created and the next run will work without error.

A minor issue but distillery ver 2.0.14 did not exhibit this behavior and PowerShell error messages are annoying to users. Thanks for looking into it!

# Import all plugins from `rel/plugins`
# They can then be used by adding `plugin MyPlugin` to
# either an environment, or release definition, where
# `MyPlugin` is the name of the plugin module.
~w(rel plugins *.exs)
|> Path.join()
|> Path.wildcard()
|> Enum.map(&Code.eval_file(&1))

use Distillery.Releases.Config,
    # This sets the default release built by `mix release`
    default_release: :default,
    # This sets the default environment used by `mix release`
    default_environment: Mix.env()

# For a full list of config options for both releases
# and environments, visit https://hexdocs.pm/distillery/config/distillery.html

# You may define one or more environments in this file,
# an environment's settings will override those of a release
# when building in that environment, this combination of release
# and environment configuration is called a profile

environment :dev do
  # If you are running Phoenix, you should make sure that
  # server: true is set and the code reloader is disabled,
  # even in dev mode.
  # It is recommended that you build with MIX_ENV=prod and pass
  # the --env flag to Distillery explicitly if you want to use
  # dev mode.
  set dev_mode: true
  set include_erts: false
  set cookie: :"VWfe!j]iw),h3]3sx_}~y</$@XtS`w$o]~@^5f`dCnOB7ABKBsOi!12hC2e{c1CP"
end

environment :prod do
  #  set include_erts: true
  set include_erts: "C:/Program Files/erl10.4"
  set include_src: false
  set cookie: :"*:E|Z!Qf=.$S!o4c$F_h7NV{th71pn16Fu_M==}wxMd>d.1SVD&|mNN*H7Wr`H}^"
  set vm_args: "rel/vm.args"
end

# You may define one or more releases in this file.
# If you have not set a default release, or selected one
# when running `mix release`, the first release in the file
# will be used by default

release :da_siteprocessing_umbrella do
  set version: "0.2.4"
  set applications: [
    :runtime_tools,
    loggix: :permanent,
    dl_posbypass_gettaghistory: :permanent,
    dl_posbypass_gettaghistory_consoleio: :permanent,
    dl_posbypass_getdepartedtags: :permanent,
    dl_posbypass_getdepartedtags_consoleio: :permanent,
    da_bar_query: :permanent,
    da_bar_query_consoleio: :permanent
  ]

  set config_providers: [{Mix.Releases.Config.Providers.Elixir, ["${RELEASE_ROOT_DIR}/etc/config.exs"]}]
  set commands: [
    execute_bar_query: "rel/commands/win/execute-bar-query.ps1",
    get_tag_history: "rel/commands/win/get-tag-history.ps1",
    get_departed_tags_from_slap: "rel/commands/win/get-departed-tags-from-slap.ps1"
  ]
  set overlays: [
    {:mkdir, "releases/<%= release_version %>/commands/win"},
    {:copy, "rel/commands/win/get-tag-history.ps1",
     "releases/<%= release_version %>/commands/win/get-tag-history.ps1"},
    {:copy, "rel/commands/win/get-departed-tags-from-slap.ps1",
     "releases/<%= release_version %>/commands/win/get-departed-tags-from-slap.ps1"},
    {:copy, "rel/commands/win/execute-bar-query.ps1",
     "releases/<%= release_version %>/commands/win/execute-bar-query.ps1"},

    {:copy, "config/config.exs", "etc/config.exs"},
    {:copy, "priv/msvcr120.dll", "erts-<%= erts_vsn %>/bin/msvcr120.dll"},
    {:copy, "priv/run-get-tag-history.bat", "bin/run-get-tag-history.bat"},
    {:copy, "priv/run-get-departed-tags-from-slap.bat", "bin/run-get-departed-tags-from-slap.bat"},
    {:copy, "priv/execute-bar-query.bat", "bin/execute-bar-query.bat"},
    {:copy, "README.md", "README.md"}
  ]
end