Startup-time configuration

This commit is contained in:
Daniel Flanagan 2020-12-17 15:23:16 -06:00
parent 5625a4d5b6
commit 8deb142ebc
Signed by: lytedev
GPG Key ID: 5B2020A0F9921EF4
6 changed files with 63 additions and 1 deletions

15
mix.exs
View File

@ -29,10 +29,25 @@ defmodule Lytedev.MixProject do
deps_path: @deps_path,
deps: deps(),
docs: docs(),
releases: releases(),
]
def application, do: [
mod: {Lytedev.Application, []},
extra_applications: [:logger],
]
def releases, do: [
lytedev: [
include_executables_for: [:unix],
applications: [runtime_tools: :permanent],
strip_beams: true,
path: Path.join(@build_path, "rel"),
include_erts: true,
rel_templates_path: Path.join(@src_path, "rel"),
# overlays: ["src/static"],
steps: [:assemble],
runtime_config_path: Path.join(@src_path, "release.exs"),
],
]
end

View File

@ -13,3 +13,16 @@ iex -S mix
```bash
mix test
```
## Generate Release
```bash
MIX_ENV=prod mix release
```
## Deploy
```bash
rsync -r ./build/rel/ $YOUR_HOST:~/my-app
ssh $YOUR_HOST ~/my-app/bin/lytedev daemon
```

View File

@ -1,6 +1,7 @@
use Mix.Config
config :lytedev, Lytedev.HttpServer, port: 3000
{port, ""} = Integer.parse(System.get_env("PORT", "3000"))
config :lytedev, Lytedev.HttpServer, port: port
config :logger, level: :debug

18
src/rel/env.sh.eex Normal file
View File

@ -0,0 +1,18 @@
#!/bin/sh
# Sets and enables heart (recommended only in daemon mode)
# case $RELEASE_COMMAND in
# daemon*)
# HEART_COMMAND="$RELEASE_ROOT/bin/$RELEASE_NAME $RELEASE_COMMAND"
# export HEART_COMMAND
# export ELIXIR_ERL_OPTIONS="-heart"
# ;;
# *)
# ;;
# esac
# Set the release to work across nodes. If using the long name format like
# the one below (my_app@127.0.0.1), you need to also uncomment the
# RELEASE_DISTRIBUTION variable below. Must be "sname", "name" or "none".
# export RELEASE_DISTRIBUTION=name
# export RELEASE_NODE=<%= @release.name %>@127.0.0.1

11
src/rel/vm.args.eex Normal file
View File

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

4
src/release.exs Normal file
View File

@ -0,0 +1,4 @@
import Config
{port, ""} = Integer.parse(System.get_env("PORT", "3000"))
config :lytedev, Lytedev.HttpServer, port: port