Skip to content

Commit 12bf29f

Browse files
committed
chore: add release configs
1 parent 137f450 commit 12bf29f

File tree

11 files changed

+85
-1
lines changed

11 files changed

+85
-1
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# The directory Mix will write compiled artifacts to.
22
/_build/
33
/.elixir_ls
4-
4+
.env
55
# If you run "mix test --cover", coverage assets end up here.
66
/cover/
77

example.env

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
SECRET_KEY_BASE=
2+
DATABASE_URL=
3+
PORT=

lib/brasil_em_dados/release.ex

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
defmodule BrasilEmDados.Release do
2+
@moduledoc """
3+
Used for executing DB release tasks when run in production without Mix
4+
installed.
5+
"""
6+
@app :brasil_em_dados
7+
8+
def migrate do
9+
load_app()
10+
11+
for repo <- repos() do
12+
{:ok, _, _} = Ecto.Migrator.with_repo(repo, &Ecto.Migrator.run(&1, :up, all: true))
13+
end
14+
end
15+
16+
def rollback(repo, version) do
17+
load_app()
18+
{:ok, _, _} = Ecto.Migrator.with_repo(repo, &Ecto.Migrator.run(&1, :down, to: version))
19+
end
20+
21+
defp repos do
22+
Application.fetch_env!(@app, :ecto_repos)
23+
end
24+
25+
defp load_app do
26+
Application.load(@app)
27+
end
28+
end

rel/env.bat.eex

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@echo off
2+
rem Set the release to work across nodes.
3+
rem RELEASE_DISTRIBUTION must be "sname" (local), "name" (distributed) or "none".
4+
rem set RELEASE_DISTRIBUTION=name
5+
rem set RELEASE_NODE=<%= @release.name %>

rel/env.sh.eex

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/sh
2+
3+
# Sets and enables heart (recommended only in daemon mode)
4+
# case $RELEASE_COMMAND in
5+
# daemon*)
6+
# HEART_COMMAND="$RELEASE_ROOT/bin/$RELEASE_NAME $RELEASE_COMMAND"
7+
# export HEART_COMMAND
8+
# export ELIXIR_ERL_OPTIONS="-heart"
9+
# ;;
10+
# *)
11+
# ;;
12+
# esac
13+
14+
# Set the release to work across nodes.
15+
# RELEASE_DISTRIBUTION must be "sname" (local), "name" (distributed) or "none".
16+
# export RELEASE_DISTRIBUTION=name
17+
# export RELEASE_NODE=<%= @release.name %>

rel/overlays/bin/migrate

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
cd -P -- "$(dirname -- "$0")"
3+
exec ./brasil_em_dados eval BrasilEmDados.Release.migrate

rel/overlays/bin/migrate.bat

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
call "%~dp0\brasil_em_dados" eval BrasilEmDados.Release.migrate

rel/overlays/bin/server

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
cd -P -- "$(dirname -- "$0")"
3+
PHX_SERVER=true exec ./brasil_em_dados start

rel/overlays/bin/server.bat

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
set PHX_SERVER=true
2+
call "%~dp0\brasil_em_dados" start

rel/remote.vm.args.eex

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
## Customize flags given to the VM: https://erlang.org/doc/man/erl.html
2+
## -mode/-name/-sname/-setcookie are configured via env vars, do not set them here
3+
4+
## Number of dirty schedulers doing IO work (file, sockets, and others)
5+
##+SDio 5
6+
7+
## Increase number of concurrent ports/sockets
8+
##+Q 65536
9+
10+
## Tweak GC to run more often
11+
##-env ERL_FULLSWEEP_AFTER 10

rel/vm.args.eex

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
## Customize flags given to the VM: https://erlang.org/doc/man/erl.html
2+
## -mode/-name/-sname/-setcookie are configured via env vars, do not set them here
3+
4+
## Number of dirty schedulers doing IO work (file, sockets, and others)
5+
##+SDio 5
6+
7+
## Increase number of concurrent ports/sockets
8+
##+Q 65536
9+
10+
## Tweak GC to run more often
11+
##-env ERL_FULLSWEEP_AFTER 10

0 commit comments

Comments
 (0)