jed

jed

Running compiled elixir app as a service(systemd)?

Hey all
I have a small elixir program compiled using Distillery 2.0 that I want to run whenever my computer boots up.
I figured it would be straight forward because it would just be running “./bin/app start” in a service, however I get the following error(s):

sudo journalctl -xe
>-- Subject: Unit zofi.service has finished start-up
>-- Defined-By: systemd
>-- Support: http://www.ubuntu.com/support
>-- 
>-- Unit zofi.service has finished starting up.
>-- 
>-- The start-up result is RESULT.
> Nov 28 15:51:51 jed-nuc7i3-04 zofi[900]: erlexec: HOME must be set
> Nov 28 15:51:51 jed-nuc7i3-04 zofi[900]: Unusable Erlang runtime system! This is likely due to being compiled for another system than the host is running
> Nov 28 15:51:51 jed-nuc7i3-04 systemd[1]: zofi.service: Main process exited, code=exited, status=1/FAILURE
> Nov 28 15:51:51 jed-nuc7i3-04 systemd[1]: zofi.service: Failed with result 'exit-code'.

-erlexec: HOME must be set
Not sure where to begin here since I haven’t seen references to ‘erlexec’ in the Distillery docs thus far.

-Unusable Erlang runtime system! This is likely due to being compiled for another system than the host is running

This is also a strange one because I’m deploying it on the same computer it was made.

Maybe I’m missing something obvious here. Any ideas?

Other Info:
OS: Ubuntu 18.04.1 LTS
Elixir 1.7.4 (compiled with Erlang/OTP 20)
Distillery version 2.0.12
rel/config.exs - Using defaults.
The service: https://pastebin.com/ZJHEikFt

Marked As Solved

alco

alco

Make sure you have set include_erts: true in your release config, this may fix the second warning.

erlexec is Erlang’s underlying binary, it starts the whole system up when you run erl. Distillery’s docs recommend using foreground instead of start here, I’d try that.

UPDATE: Just to elaborate a bit on erlexec, for posterity:

$ which erl
/usr/bin/erl

$ ls -l /usr/bin/erl
lrwxrwxrwx 1 root root 22 Sep 28 19:37 /usr/bin/erl -> ../lib/erlang//bin/erl*

$ cat /usr/lib/erlang/bin/erl
#!/bin/sh

<snip>

ROOTDIR="/usr/lib/erlang"
BINDIR=$ROOTDIR/erts-10.1/bin

<snip>

exec "$BINDIR/erlexec" ${1+"$@"}
# This is the actual executable file that starts the Erlang system up
$ file /usr/lib/erlang/erts-10.1/bin/erlexec
/usr/lib/erlang/erts-10.1/bin/erlexec: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=870fd3e2d6d8ace6d2c09044bd3545659c0691a0, stripped

Also Liked

jed

jed

Thanks everyone.
Turns out I just needed to run mix release with MIX_ENV=prod to compile to a proper production version with set_include_erts set to true. When previously I was just including the flag --env=prod, thinking it was sufficient.

OvermindDL1

OvermindDL1

You should look at my PidFile - create and manage a PID file from the BEAM process thread, I have a systemd service description there that works well and I’ve been using for over a year now. You don’t need pid_file itself now as I think Distillery 2 baked in it’s functionality now, but check it’s docs to make sure (and to get the path to use). pid_file still works fine otherwise (I’m still using it). :slight_smile:

jed

jed

Cool project. I might check this out if my little project grows into into something non-trivial :slightly_smiling_face:

Where Next?

Popular in Questions Top

pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
LegitStack
I’m hoping you guys can give me some general advice and perhaps code examples if you’re feeling up to it. I’m very interested in Elixir,...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 record...
New
Werner
Hi, I’m using Ubuntu 18.04 and after updating to OTP-24.0 yesterday i have this warning when I run “mix local.hex”: 14:57:30.512 [warn] ...
New
fireproofsocks
I’m working on defining a simple Ecto schema for a table (in PostGres), but I don’t see where I can define a column as NOT NULL. Conside...
New
sacepums
Hey guys. I'm new to elixir and im really stocked about it. But I ran into a bit of problem - I need to convert a date sting, for examp...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New

Other popular topics Top

openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
itssasanka
Hi all, Trying to get some more clarity over utc_datetime and naive_datetime for Ecto: https://hexdocs.pm/ecto/Ecto.Schema.html#module-...
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
script
If I have a string “1000 cfu/ml” . I want to remove the characters and / and space . So the string is like this "1000" What is the ...
New
qwerescape
Is there a way to get the call stack or stack trace at any point in the code? Not from exceptions, but an expression that returns how the...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? https://hexdocs.pm/ecto/Ecto.Repo.h...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
magnetic
Hey :wave:t3: Elixir community, I’ve been learning Elixir, and working on some side projects. My editor of choice is VSCode, and althoug...
New

We're in Beta

About us Mission Statement