diff --git a/mix.exs b/mix.exs index 16727b9..c93de77 100644 --- a/mix.exs +++ b/mix.exs @@ -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 diff --git a/readme.md b/readme.md index fe33dc7..67891b2 100644 --- a/readme.md +++ b/readme.md @@ -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 +``` diff --git a/src/config.exs b/src/config.exs index 951e5cc..94bb01b 100644 --- a/src/config.exs +++ b/src/config.exs @@ -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 diff --git a/src/rel/env.sh.eex b/src/rel/env.sh.eex new file mode 100644 index 0000000..382cd83 --- /dev/null +++ b/src/rel/env.sh.eex @@ -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 diff --git a/src/rel/vm.args.eex b/src/rel/vm.args.eex new file mode 100644 index 0000000..957d983 --- /dev/null +++ b/src/rel/vm.args.eex @@ -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 diff --git a/src/release.exs b/src/release.exs new file mode 100644 index 0000000..8c8ae42 --- /dev/null +++ b/src/release.exs @@ -0,0 +1,4 @@ +import Config + +{port, ""} = Integer.parse(System.get_env("PORT", "3000")) +config :lytedev, Lytedev.HttpServer, port: port