Skip to content

Commit

Permalink
integrating releases
Browse files Browse the repository at this point in the history
  • Loading branch information
SonaTigranyan committed May 24, 2020
1 parent 993a448 commit 73b3b34
Show file tree
Hide file tree
Showing 8 changed files with 122 additions and 15 deletions.
11 changes: 0 additions & 11 deletions config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,3 @@ import Config
config :diop_core,
"text/csv": DiopCore.Controller

config :eximap,
account: "sona",
password: "foobarbaz",
use_ssl: true,
incoming_mail_server: "post.pingvinashen.am",
incoming_port: 993


config :diop_email,
check_list: ["evncert.am", "pingvinashen.am"]

16 changes: 14 additions & 2 deletions rel/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ end
environment :prod do
set include_erts: true
set include_src: false
set cookie: :"EoX>S}.4buQp9|MS&2NSQ&pFFqm<5kmyR>FCzKe)Sy{/8>2[?GQ!!.Sme}s=cu0N"
set vm_args: "rel/vm.args"
end

Expand All @@ -51,5 +50,18 @@ release :diop_core do
set applications: [
:runtime_tools
]
end

set pre_configure_hooks: "rel/hooks/pre_configure"
set pre_start_hooks: "rel/hooks/pre_start"
set post_start_hooks: "rel/hooks/post_start"

set overlays: [
{:template, "rel/dioprc.example.eex", "dioprc.example"},
{:copy, "rel/provider.exs", "releases/<%= release.version %>/provider.exs"}
]

set config_providers: [
{Distillery.Releases.Config.Providers.Elixir,
["${RELEASE_ROOT_DIR}/releases/${REL_VSN}/provider.exs"]}
]
end
23 changes: 23 additions & 0 deletions rel/dioprc.example.eex
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/sh


## Erlang Distribution Configuration

## (required) unique nodename for erlang distribution
export NODE_NAME=<%= release.name %>@127.0.0.1

## (required) secure secret key, at least 64 bytes in length
export NODE_COOKIE=


## IMAP Configuration

## (required) IMAP username, IMAP user password
export IMAP_USERNAME=
export IMAP_PASSWORD=

## (optional, defaults to localhost) IMAP server host
#export IMAP_HOST=

## (optional, defaults to 993) IMAP server port
#export IMAP_PORT=
3 changes: 3 additions & 0 deletions rel/hooks/post_start/post_start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

printf '\e[1;94m%-6s\e[m\n' "Done."
41 changes: 41 additions & 0 deletions rel/hooks/pre_configure/pre_configure.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env bash

export REPLACE_OS_VARS=true

printf "==> checking environment variables\n"

if [ -f "$RELEASE_ROOT_DIR/dioprc" ]; then
printf "Sourcing dioprc...\n"
source "$RELEASE_ROOT_DIR/dioprc"
else
printf "dioprc not found :(\n"
exit 1
fi

if [ -z "$NODE_NAME" ]; then
printf '$NODE_NAME is not set... exiting.\n'
exit 1
else
printf "Node name -> ${NODE_NAME}\n"
fi

if [ -z "$NODE_COOKIE" ]; then
printf '$NODE_COOKIE is not set... exiting.\n'
exit 1
else
printf "Node cookie is set\n"
fi

if [ -z "$IMAP_USERNAME" ]; then
printf '$IMAP_USERNAME is not set... exiting.\n'
exit 1
else
printf "IMAP username is set\n"
fi

if [ -z "$IMAP_PASSWORD" ]; then
printf '$IMAP_PASSWORD is not set... exiting.\n'
exit 1
else
printf "IMAP password is set\n"
fi
3 changes: 3 additions & 0 deletions rel/hooks/pre_start/pre_start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

printf '\e[0;94m%-6s\e[m\n' "Starting DIOP..."
36 changes: 36 additions & 0 deletions rel/provider.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
use Mix.Config

# Node
node_name = System.get_env("NODE_NAME")
node_cookie = System.get_env("NODE_COOKIE")

#IMAP
imap_username = System.get_env("IMAP_USERNAME")
imap_password = System.get_env("IMAP_PASSWORD")
imap_host =
case System.get_env("IMAP_HOST") do
nil -> "localhost"
host -> host
end

imap_port =
case System.get_env("IMAP_PORT") do
nil -> 993
port -> port |> String.to_integer
end


config :diop_core,
node_name: node_name,
node_cookie: node_cookie

config :eximap,
account: imap_username,
password: imap_password,
use_ssl: true,
incoming_mail_server: imap_host,
incoming_port: imap_port


config :diop_email,
check_list: ["evncert.am", "pingvinashen.am"]
4 changes: 2 additions & 2 deletions rel/vm.args
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
## http://erlang.org/doc/man/erl.html

## Name of the node
-name <%= release_name %>@127.0.0.1
-name ${NODE_NAME}

## Cookie for distributed erlang
-setcookie <%= release.profile.cookie %>
-setcookie ${NODE_COOKIE}

## Heartbeat management; auto-restarts VM if it dies or becomes unresponsive
## (Disabled by default..use with caution!)
Expand Down

0 comments on commit 73b3b34

Please sign in to comment.