diff --git a/config/prod.exs b/config/prod.exs index 2d537e10..8dbbd841 100644 --- a/config/prod.exs +++ b/config/prod.exs @@ -14,7 +14,7 @@ config :philomena, PhilomenaWeb.Endpoint, cache_static_manifest: "priv/static/cache_manifest.json" # Do not print debug messages in production -config :logger, level: :info +config :logger, level: :warn # ## SSL Support # diff --git a/mix.exs b/mix.exs index 46b67275..134dd7d4 100644 --- a/mix.exs +++ b/mix.exs @@ -20,7 +20,7 @@ defmodule Philomena.MixProject do def application do [ mod: {Philomena.Application, []}, - extra_applications: [:logger, :runtime_tools] + extra_applications: [:logger, :canada, :mnesia, :runtime_tools] ] end diff --git a/post-receive b/post-receive new file mode 100755 index 00000000..e6eac338 --- /dev/null +++ b/post-receive @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +# Set up environment +source ~/bin/philomena-env + +read oldrev newrev ref +echo "Updating $oldrev -> $newrev ($ref)" + +# Clear variable set to '.' so git commands don't complain +unset GIT_DIR + +die() { + echo "$*" 1>&2 + exit 1 +} + +if git diff --name-only $oldrev $newrev | grep "^mix.exs"; then + echo "Fetching deps" + mix deps.get || die "mix failed to update" +fi + +# Run migrations +if git diff --name-only $oldrev $newrev | grep "^priv/repo/migrations"; then + echo "Running database migrations" + mix ecto.migrate || die "ecto.migrate failed" +fi + +# Compile assets +if git diff --name-only $oldrev $newrev | grep "^assets/"; then + echo "Compiling assets" + npm run deploy --prefix ./assets + mix phx.digest || die "assets compile failed" +fi + +# Generate release name to always be the current timestamp so that +# it will be considered an upgrade +export PHILOMENA_VERSION="0.1.0.$(date +%s)" + +mix distillery.release || die "failed to generate release" + +_build/prod/rel/philomena/bin/philomena upgrade $PHILOMENA_VERSION || die "failed to upgrade app; log in to the server and restart the app manually" \ No newline at end of file diff --git a/rel/config.exs b/rel/config.exs index 7b88a9eb..819bf4a3 100644 --- a/rel/config.exs +++ b/rel/config.exs @@ -52,7 +52,8 @@ end release :philomena do set version: current_version(:philomena) set applications: [ - :runtime_tools + :runtime_tools, + philomena: :permanent ] end