Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 30 May 2019 15:48:24 -0500
From:      Joe Love <joe@getsomewhere.net>
To:        Dave Cottlehuber <dch@skunkwerks.at>
Cc:        erlang@freebsd.org
Subject:   Re: Deploying program on erlang runtime 21
Message-ID:  <18BC9005-CDE4-43A8-8EC0-F4D7556E20EC@getsomewhere.net>
In-Reply-To: <36da7161-b304-4456-8027-d12eba2ac217@www.fastmail.com>
References:  <4259DD93-00E2-4EB6-A1C3-DC4CBCEDD34C@getsomewhere.net> <36da7161-b304-4456-8027-d12eba2ac217@www.fastmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help

> On May 30, 2019, at 7:50 AM, Dave Cottlehuber <dch@skunkwerks.at> =
wrote:
>=20
> 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-based=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 =
some guidance here.
>>=20
>> I=E2=80=99ve created my project on my mac.  I=E2=80=99ve added =
Distillery (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 =
the 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 =
server=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/erlang=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-based=20
>> programs on a different machine than that you=E2=80=99re building it =
on.
>>=20
>> Thanks,
>> -Joe
>=20
> Hey Joe,
>=20
> welcome. I deploy to FreeBSD with Elixir & distillery 2.0 without any =
issues.=20
> The simple fix is to move off OSX to FreeBSD like I did and then this =
problem
> goes away ;-).
>=20
> TLDR: build your releases on the same OS+package as your deploy =
target.
>=20
> 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 =
versions
> of runtime and related libraries. If your Mac-based OTP release is =
*exactly*
> the same as the FreeBSD one, *and* you have no NIFs, then it's =
possible
> to get this working.
>=20
> 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 =
distillery
> release, and simply pkg-install those.
>=20
> 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.
>=20
> details:
>=20
> 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.
>=20
> erts (Erlang RunTime System) has different patch levels and point =
releases.
> The OTP 21 runtime on your Mac may not be the same one you're =
deploying
> to.
>=20
> 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
>=20
> 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 =
release
> is *very* specific about what it requires.
>=20
> 2. if you have NIF modules (native C code) then this definitely won't =
work
> as the linked libraries aren't remotely compatible.
>=20
> 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

Hi Dave,

Thanks for following up.  I look forward to reading any sort of write-up =
you might make on the subject, but I get the short answer: =E2=80=9CCompil=
e it on FreeBSD.=E2=80=9D

I know I=E2=80=99ve seen the emails on the mailing list regarding =
updating lang/erlang to 21, so I=E2=80=99ll get my ports tree updated =
and go from there.

Thanks,
-Joe




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?18BC9005-CDE4-43A8-8EC0-F4D7556E20EC>