Packages
version_tasks
0.10.0
0.12.0
0.11.4
0.11.3
0.11.2
0.11.1
0.11.0
0.10.29
0.10.28
0.10.27
0.10.26
0.10.25
0.10.24
0.10.23
0.10.22
0.10.21
0.10.20
0.10.19
0.10.18
0.10.17
0.10.16
0.10.15
0.10.14
0.10.13
0.10.12
0.10.11
0.10.10
0.10.9
0.10.8
0.10.7
0.10.6
0.10.5
0.10.4
0.10.3
0.10.1
0.10.0
0.9.4
0.9.3
0.9.2
0.9.1
0.9.0
0.8.3
0.8.1
0.7.0
0.6.0
0.5.0
0.4.0
0.3.3
0.3.1
0.2.6
A suite of mix tasks for managing your libs version numbers with git and hex
Current section
Files
Jump to
Current section
Files
lib/mix/tasks/release/bin.ex
defmodule Mix.Tasks.Release.Bin do
use Mix.Task
@shortdoc "Initialize and create 'bin/run' helper scripts for managing releases"
def run(_) do
Mix.Task.run("release.init", [])
:ok = "./bin/run" |> Path.expand |> File.mkdir_p!
appname = Mix.Project.config[:app]
module_name = appname |> Atom.to_string |> Macro.camelize
"""
#!/bin/bash
source ./bin/env && \\
_build/prod/rel/#{appname}/bin/#{appname} console
"""
|> write!("./bin/run/console")
"""
#!/bin/bash
source ./bin/env && \\
_build/prod/rel/#{appname}/bin/#{appname} start
"""
|> write!("./bin/run/daemon")
"""
#!/bin/bash
source ./bin/env && \\
_build/prod/rel/#{appname}/bin/#{appname} foreground $1
"""
|> write!("./bin/run/foreground")
"""
#!/bin/bash
source ./bin/env && \\
_build/prod/rel/#{appname}/bin/#{appname} $@
"""
|> write!("./bin/run/rel")
"""
defmodule #{module_name}.Release do
@doc\"""
EXRM upgrades were not (for me anyway) clearning the assets
cache, so this called after an upgrade using RPC, something LexicalTracker.
./bin/run/rel rpc #{module_name}.Release clear_cache
This was based on help from
https://github.com/bitwalker/exrm/issues/206
\"""
def clear_cache do
Phoenix.Config.clear_cache #{module_name}.Web.Endpoint
Phoenix.Endpoint.Supervisor.warmup #{module_name}.Web.Endpoint
end
end
"""
|> write!("./lib/#{appname}/release.ex")
"""
#!/bin/bash
source ./bin/env && \\
_build/prod/rel/#{appname}/bin/#{appname} upgrade $1 && \\
./bin/run/rel rpc Elixir.#{module_name}.Release clear_cache
"""
|> write!("./bin/run/upgrade")
"""
#!/bin/bash
source ./bin/env && \\
_build/prod/rel/#{appname}/bin/#{appname} downgrade $1
"""
|> write!("./bin/run/downgrade")
["console", "daemon", "downgrade", "foreground", "rel", "upgrade"]
|> Enum.each(fn filename ->
:ok = "./bin/run/#{filename}"
|> Path.expand
|> File.chmod(0o755)
end)
IO.puts "Installed several release scripts into ./bin/run"
end
defp write!(content, relative_name) do
File.write!(relative_name |> Path.expand, content)
end
end