Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 30 May 2019 12:50:06 +0000
From:      "Dave Cottlehuber" <dch@skunkwerks.at>
To:        "Joe Love" <joe@getsomewhere.net>, erlang@freebsd.org
Subject:   Re: Deploying program on erlang runtime 21
Message-ID:  <36da7161-b304-4456-8027-d12eba2ac217@www.fastmail.com>
In-Reply-To: <4259DD93-00E2-4EB6-A1C3-DC4CBCEDD34C@getsomewhere.net>
References:  <4259DD93-00E2-4EB6-A1C3-DC4CBCEDD34C@getsomewhere.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, 29 May 2019, at 20:31, Joe Love wrote:
> Hi,
>=20
> I=E2=80=99ve been trying to wrap my head around creating my Elixir-bas=
ed=20
> projects on my client workstations (which are not freebsd) and=20
> deploying them to a FreeBSD server using the erlang-runtime-21 package=
.
>=20
> I think I=E2=80=99m a bit lost somewhere on it, and am hoping to get s=
ome guidance here.
>=20
> I=E2=80=99ve created my project on my mac.  I=E2=80=99ve added Distill=
ery (per many=20
> suggestions & guides).  If I understand everything correctly, I can=E2=
=80=99t=20
> include ERTS, as that=E2=80=99s the part which is compiled based on th=
e host=20
> OS.  Therefore, I modified my Distillery config to not include ERTS in=
=20
> the production build, and then ran `mix release --env=3Dprod`.
>=20
> I uploaded the resulting _build/dev/rel/myproject to the FreeBSD serve=
r=20
> which has erlang-runtime-21 on it.
> I set my path to include /usr/local/lib/erlang21/bin, added=20
> ERTS_LIB_DIR =3D /usr/local/lib/erlang21/erts-10.3 and tried to run it=
. =20
> Apparently I have erts-10.1 on my machine and the server had erts-10.3=
,=20
> so it seems that that also needs to match.
>=20
> So, given all of this, I remember being told that while the lang/erlan=
g=20
> port was older, that I could always use the runtime ports, and things=20=

> would work.  Can someone fill me in on how they're supposed to work? =20=

> It seems like things are more intricate regarding running beam-vm-base=
d=20
> programs on a different machine than that you=E2=80=99re building it o=
n.
>=20
> Thanks,
> -Joe

Hey Joe,

welcome. I deploy to FreeBSD with Elixir & distillery 2.0 without any is=
sues.=20
The simple fix is to move off OSX to FreeBSD like I did and then this pr=
oblem
goes away ;-).

TLDR: build your releases on the same OS+package as your deploy target.

If you unpack the .tar.gz that distillery creates, you'll see inside a .=
/releases/
folder. the RELEASES and *.rel and start_erl.data all specify explicit v=
ersions
of runtime and related libraries. If your Mac-based OTP release is *exac=
tly*
the same as the FreeBSD one, *and* you have no NIFs, then it's possible
to get this working.

IMHO getting cross-compilation etc sorted isn't worth it when you can
build in a jail anyway. I then create FreeBSD packages from the distille=
ry
release, and simply pkg-install those.

I'll write this up and post a link to it tomorrow on how to do this, it'=
s
too long to fit in an email.

details:

1. always build releases on the same OS+arch+BEAM+packages as you
intend to deploy to. Cross-building is possible but surprisingly tricky.=

If the patch versions are different, stuff may not start.

erts (Erlang RunTime System) has different patch levels and point releas=
es.
The OTP 21 runtime on your Mac may not be the same one you're deploying
to.

The FreeBSD ones have just this week been updated and moved to a much
easier-to-update system (thanks olgeni@ ) so we should be staying pretty=

up to date with official releases now. We have OTP21,22 and Elixir 1.8.2=


Right now, that's 21.3.8.2 which has different modules from the original=

OTP 21.0 shipped months ago -
asn1, crypto, kernel, ssl, stdlib, & more have all evolved. Your mac
built release probably won't have the same modules on it, and the releas=
e
is *very* specific about what it requires.

2. if you have NIF modules (native C code) then this definitely won't wo=
rk
as the linked libraries aren't remotely compatible.

3. Every time the lang/erlang-* port is updated, you'll need to rebuild =
your
application (if you're not including erts).
=20
A+
Dave



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?36da7161-b304-4456-8027-d12eba2ac217>