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:

Last Post!

sahilpaudel

sahilpaudel

I did the same but still getting

/var/app/_build/prod/rel/afterglow/erts-10.3/bin/erlexec: 1: /var/app/_build/prod/rel/afterglow/erts-10.3/bin/erlexec: Syntax error: "(" unexpected
Unusable Erlang runtime system! This is likely due to being compiled for another system than the host is running
/var/app/_build/prod/rel/afterglow/erts-10.3/bin/erlexec: 1: /var/app/_build/prod/rel/afterglow/erts-10.3/bin/erlexec: Syntax error: "(" unexpected
Unusable Erlang runtime system! This is likely due to being compiled for another system than the host is running
/var/app/_build/prod/rel/afterglow/erts-10.3/bin/erlexec: 1: /var/app/_build/prod/rel/afterglow/erts-10.3/bin/erlexec: Syntax error: "(" unexpected
Unusable Erlang runtime system! This is likely due to being compiled for another system than the host is running

Where Next?

Popular in Questions Top

lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
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
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New

Other popular topics Top

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
JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 31586 112
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New

We're in Beta

About us Mission Statement