diff --git a/config/dev.exs b/config/dev.exs index c525327..f048dea 100644 --- a/config/dev.exs +++ b/config/dev.exs @@ -70,3 +70,5 @@ config :fd, :social, config :fd, :monitoring_alerts, false config :fd, :admin_instances, [1] +import_config "dev.secret.exs" + diff --git a/mix.exs b/mix.exs index f804f72..37e6a30 100644 --- a/mix.exs +++ b/mix.exs @@ -43,7 +43,7 @@ defmodule Fd.Mixfile do {:cowboy, "~> 1.0"}, {:hackney, "~> 1.12.1", override: true}, {:httpoison, "~> 1.0", override: true}, - {:distillery, "~> 1.5", runtime: false}, + {:distillery, github: "bitwalker/distillery"}, {:jason, "~> 1.0"}, {:idna, "~> 5.1", override: true}, {:public_suffix, "~> 0.6.0"}, diff --git a/mix.lock b/mix.lock index 965a16e..dd0c3ac 100644 --- a/mix.lock +++ b/mix.lock @@ -1,5 +1,6 @@ %{ "accept": {:hex, :accept, "0.3.3", "548ebb6fb2e8b0d170e75bb6123aea6ceecb0189bb1231eeadf52eac08384a97", [:rebar3], [], "hexpm"}, + "artificery": {:hex, :artificery, "0.2.6", "f602909757263f7897130cbd006b0e40514a541b148d366ad65b89236b93497a", [:mix], [], "hexpm"}, "certifi": {:hex, :certifi, "2.3.1", "d0f424232390bf47d82da8478022301c561cf6445b5b5fb6a84d49a9e76d2639", [:rebar3], [{:parse_trans, "3.2.0", [hex: :parse_trans, repo: "hexpm", optional: false]}], "hexpm"}, "combine": {:hex, :combine, "0.10.0", "eff8224eeb56498a2af13011d142c5e7997a80c8f5b97c499f84c841032e429f", [:mix], [], "hexpm"}, "connection": {:hex, :connection, "1.0.4", "a1cae72211f0eef17705aaededacac3eb30e6625b04a6117c1b2db6ace7d5976", [:mix], [], "hexpm"}, @@ -7,7 +8,7 @@ "cowlib": {:hex, :cowlib, "1.0.2", "9d769a1d062c9c3ac753096f868ca121e2730b9a377de23dec0f7e08b1df84ee", [:make], [], "hexpm"}, "db_connection": {:hex, :db_connection, "1.1.3", "89b30ca1ef0a3b469b1c779579590688561d586694a3ce8792985d4d7e575a61", [:mix], [{:connection, "~> 1.0.2", [hex: :connection, repo: "hexpm", optional: false]}, {:poolboy, "~> 1.5", [hex: :poolboy, repo: "hexpm", optional: true]}, {:sbroker, "~> 1.0", [hex: :sbroker, repo: "hexpm", optional: true]}], "hexpm"}, "decimal": {:hex, :decimal, "1.5.0", "b0433a36d0e2430e3d50291b1c65f53c37d56f83665b43d79963684865beab68", [:mix], [], "hexpm"}, - "distillery": {:hex, :distillery, "1.5.3", "b2f4fc34ec71ab4f1202a796f9290e068883b042319aa8c9aa45377ecac8597a", [:mix], [], "hexpm"}, + "distillery": {:git, "https://github.com/bitwalker/distillery.git", "87b4e9569cd56a083af2a57f3ca69d9c241082a9", []}, "earmark": {:hex, :earmark, "1.2.5", "4d21980d5d2862a2e13ec3c49ad9ad783ffc7ca5769cf6ff891a4553fbaae761", [:mix], [], "hexpm"}, "ecto": {:hex, :ecto, "2.2.10", "e7366dc82f48f8dd78fcbf3ab50985ceeb11cb3dc93435147c6e13f2cda0992e", [:mix], [{:db_connection, "~> 1.1", [hex: :db_connection, repo: "hexpm", optional: true]}, {:decimal, "~> 1.2", [hex: :decimal, repo: "hexpm", optional: false]}, {:mariaex, "~> 0.8.0", [hex: :mariaex, repo: "hexpm", optional: true]}, {:poison, "~> 2.2 or ~> 3.0", [hex: :poison, repo: "hexpm", optional: true]}, {:poolboy, "~> 1.5", [hex: :poolboy, repo: "hexpm", optional: false]}, {:postgrex, "~> 0.13.0", [hex: :postgrex, repo: "hexpm", optional: true]}, {:sbroker, "~> 1.0", [hex: :sbroker, repo: "hexpm", optional: true]}], "hexpm"}, "ex2ms": {:hex, :ex2ms, "1.5.0", "19e27f9212be9a96093fed8cdfbef0a2b56c21237196d26760f11dfcfae58e97", [:mix], [], "hexpm"}, diff --git a/rel/config.exs b/rel/config.exs index d702735..b490082 100644 --- a/rel/config.exs +++ b/rel/config.exs @@ -37,7 +37,8 @@ environment :prod do set include_erts: true set include_src: false set cookie: :"cHnD:SCPw9]Q[^)HS^AM>>^nm^?:TV4!bjr)0FgS9>8.{i(b!gqXAt]N|5z$b}Ej" - set post_start_hook: "rel/hooks/post_start.sh" + set post_start_hooks: "rel/hooks/" + #set post_start_hooks: "rel/hooks/post_start.sh" end # You may define one or more releases in this file. diff --git a/rel/hooks/post_start.sh b/rel/hooks/post_start.sh index 5b12a4f..ed18e3f 100644 --- a/rel/hooks/post_start.sh +++ b/rel/hooks/post_start.sh @@ -1,13 +1,27 @@ -set +e +#!/usr/bin/env bash -echo "Starting app." -echo "Waiting for node" +set -o posix + +## Pings the running node, or an arbitrary peer node +## by supplying `--peer` and `--cookie` flags. +## +## If the node is running and can be connected to, +## 'pong' will be printed to stdout. If the node is +## not reachable or cannot be connected to due to an +## invalid cookie, 'pang' will be printed to stdout +## and the command will exit with a non-zero status code. + +set -e + +require_cookie + +echo "Waiting for node." while true; do - nodetool ping > /dev/null + release_ctl ping --peer="$NAME" --cookie="$COOKIE" "$@" > /dev/null EXIT_CODE=$? if [ $EXIT_CODE -eq 0 ]; then - echo " up!" + echo " up." break fi echo -n "." @@ -16,6 +30,10 @@ done set -e echo "-*- Running migrations" -bin/fd rpc Elixir.Fd.ReleaseTasks migrate + +require_live_node + +release_remote_ctl rpc "Fd.ReleaseTasks.migrate()" + echo "-*- Migrations run successfully"