Deploying program on erlang runtime 21

Joe Love joe at getsomewhere.net
Thu May 30 20:48:28 UTC 2019


> On May 30, 2019, at 7:50 AM, Dave Cottlehuber <dch at skunkwerks.at> wrote:
> 
> On Wed, 29 May 2019, at 20:31, Joe Love wrote:
>> Hi,
>> 
>> I’ve been trying to wrap my head around creating my Elixir-based 
>> projects on my client workstations (which are not freebsd) and 
>> deploying them to a FreeBSD server using the erlang-runtime-21 package.
>> 
>> I think I’m a bit lost somewhere on it, and am hoping to get some guidance here.
>> 
>> I’ve created my project on my mac.  I’ve added Distillery (per many 
>> suggestions & guides).  If I understand everything correctly, I can’t 
>> include ERTS, as that’s the part which is compiled based on the host 
>> OS.  Therefore, I modified my Distillery config to not include ERTS in 
>> the production build, and then ran `mix release --env=prod`.
>> 
>> I uploaded the resulting _build/dev/rel/myproject to the FreeBSD server 
>> which has erlang-runtime-21 on it.
>> I set my path to include /usr/local/lib/erlang21/bin, added 
>> ERTS_LIB_DIR = /usr/local/lib/erlang21/erts-10.3 and tried to run it.  
>> Apparently I have erts-10.1 on my machine and the server had erts-10.3, 
>> so it seems that that also needs to match.
>> 
>> So, given all of this, I remember being told that while the lang/erlang 
>> port was older, that I could always use the runtime ports, and things 
>> would work.  Can someone fill me in on how they're supposed to work?  
>> It seems like things are more intricate regarding running beam-vm-based 
>> programs on a different machine than that you’re building it on.
>> 
>> Thanks,
>> -Joe
> 
> Hey Joe,
> 
> welcome. I deploy to FreeBSD with Elixir & distillery 2.0 without any issues. 
> The simple fix is to move off OSX to FreeBSD like I did and then this problem
> 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 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.
> 
> 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.
> 
> 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 releases.
> 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 release
> is *very* specific about what it requires.
> 
> 2. if you have NIF modules (native C code) then this definitely won't work
> 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).
> 
> 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: “Compile it on FreeBSD.”

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

Thanks,
-Joe



More information about the freebsd-erlang mailing list