mix horizon.init (horizon v0.3.4)
View SourceCreates Horizon deploy scripts in bin/ and rel/ directories.
Usage
mix horizon.init [-y]Options
-y- Overwrite files without asking for confirmation.
Description
Horizon.Init creates scripts for deploying an Elixir application to a host.
See Horizon.Ops.Init for the creation for additional helper applications.
Scripts are created in the bin/ directory of the project by default,
but each release defined in mix.exs may override the default path
by setting the bin_path option.
The run control script for each release is created in rel/overlays/rc_d/ when mix release is run.
Customization
Horizon.Init uses the releases configuration in mix.exs to customize the deployment scripts.
The available options are:
bin_path:[bin/]- This is the directory where the scripts are created. If there is a
bin_pathfor each release, scripts associated with each release are copied to their respective bin directory.
- This is the directory where the scripts are created. If there is a
path:[/usr/local/<release_name>]- This is the final destination of the release on the deploy host. This will be the same on deploy only hosts and the build host.
build_host_ssh:[nil]- If not provided,
stagescript will use env varBUILD_HOST_SSH. Required for thestagescript to copy the release to the build machine and for thebuildscript. - Example:
[user@]host
- If not provided,
deploy_hosts_ssh:[[]]- If not provided, ssh hosts may be passed to the
deployscript with the-hoption. - Example:
user@host1,user@host2
- If not provided, ssh hosts may be passed to the
release_commands:[[]]- A list of commands to run after the release is copied to the deploy machine.
- These are typically zero arity commands defined in
release.ex. For example,["migrate"].
releases_path:[.releases]- The directory where releases are stored on the local host. The build script places the release tarball in this directory and the deploy script copies the release from this directory.
env_path:[rel/overlays/.env]- The path to the environment file that is sourced during the build process. This is particularly important when using
Application.compile_envas the environment variables are required for compilation.
- The path to the environment file that is sourced during the build process. This is particularly important when using
Files Created
Running mix horizon.init creates several files in the bin_path directory.
For the project my_app, these files include:
bin/horizon_helpers.shbin/stage-my_app.shbin/build-my_app.shbin/build_script-my_app.shbin/deploy-my_app.shbin/deploy_script-my_app.sh
If you have multiple releases, a stage, build and deploy script
is created for each release.
For example, imagine you have releases app_web and app_worker.
Horizon.Ops.Init will create
bin/horizon_helpers.shbin/stage-app_web.shbin/build-app_web.shbin/build_script-app_web.shbin/deploy-app_web.shbin/deploy_script-app_web.shbin/stage-app_worker.shbin/build-app_worker.shbin/build_script-app_worker.shbin/deploy-app_worker.shbin/deploy_script-app_worker.sh