This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Features do | |
use GenServer | |
@features [chat: true] | |
def enable(feature), do: GenServer.call(__MODULE__, {:toggle, feature, true}) | |
def disable(feature), do: GenServer.call(__MODULE__, {:toggle, feature, false}) | |
def enabled?(feature) do | |
case :ets.lookup(__MODULE__, feature) do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This is not meant to be comprehensive, a guide, or anything quite that sophisticated, just a couple | |
notes on what I do at work, in production, and how my environment is set up. | |
Overview: | |
- Infrastructure runs on AWS | |
- We run an internal PaaS based on OpenShift Origin/Kubernetes | |
- We push code to GitHub, which triggers a webhook, which in turn | |
triggers OpenShift to start a build, which fetches the source | |
code, and runs the build using the Dockerfile contained in the |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM bitwalker/alpine-erlang:latest | |
MAINTAINER Paul Schoenfelder <[email protected]> | |
ENV REFRESHED_AT=2016-06-21 \ | |
HOME=/opt/app/ \ | |
MIX_ENV=prod \ | |
TERM=xterm \ | |
APP=myapp \ | |
APPVER=0.1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM bitwalker/alpine-erlang:latest | |
MAINTAINER Paul Schoenfelder <[email protected]> | |
ENV REFRESHED_AT=2016-06-21 \ | |
HOME=/opt/app/ \ | |
MIX_ENV=prod \ | |
TERM=xterm \ | |
REPLACE_OS_VARS=true | |
EXPOSE 5000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Config do | |
@moduledoc """ | |
This module handles fetching values from the config with some additional niceties | |
""" | |
@doc """ | |
Fetches a value from the config, or from the environment if {:system, "VAR"} | |
is provided. | |
An optional default value can be provided if desired. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -x | |
term_handler() { | |
echo "Stopping the server process with PID $PID" | |
erl -noshell -name "[email protected]" -eval "rpc:call('[email protected]', init, stop, [])" -s init stop | |
echo "Stopped" | |
} | |
trap 'term_handler' TERM INT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Config do | |
@moduledoc """ | |
This module handles fetching values from the config with some additional niceties | |
""" | |
@doc """ | |
Fetches a value from the config, or from the environment if {:system, "VAR"} | |
is provided. | |
An optional default value can be provided if desired. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[centos@ip-172-22-245-135 ~]$ sudo iptables -L -n -v | |
Chain INPUT (policy ACCEPT 0 packets, 0 bytes) | |
pkts bytes target prot opt in out source destination | |
681K 129M ACCEPT all -- tun0 * 0.0.0.0/0 0.0.0.0/0 /* traffic from docker for internet */ | |
743K 517M ACCEPT udp -- * * 0.0.0.0/0 0.0.0.0/0 multiport dports 4789 /* 001 vxlan incoming */ | |
2825K 2958M ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED | |
336 29457 ACCEPT icmp -- * * 0.0.0.0/0 0.0.0.0/0 | |
59589 3575K ACCEPT all -- lo * 0.0.0.0/0 0.0.0.0/0 | |
1786 99404 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:22 | |
6827 429K OS_FIREWALL_ALLOW all -- * * 0.0.0.0/0 0.0.0.0/0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is our function definition, | |
# It is body (not tail) recursive, as it must wait for | |
# len(tail) to return before the addition can be performed | |
# on each iteration | |
def len([]), do: 0 | |
def len([head | tail]), do: 1 + len(tail) | |
# If we call len([1, 2, 3]), this is what happens | |
len([1, 2, 3]) == 1 + len([2, 3]) | |
len([2, 3]) == 1 + len([3]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule MyApp do | |
use Application | |
def start(_type, _args) do | |
import Supervisor.Spec, warn: false | |
:ok = handle_args! | |
children = [] | |
Supervisor.start_link(children, strategy: :one_for_one, name: MyApp.Supervisor) |
NewerOlder