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

sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
johnnyicon
Hi all, I’ve just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I’m trying to use Postgres...
New
LegitStack
I’m trying to make a websocket server in Phoenix or raw Elixir. I heard about gun, I think I could use cowboy, but since I’m not that sma...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
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
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
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
marick
I had some trouble figuring out how to make many-to-many associations work. Once I got it working, I wrote a blog post. Because I’m a nov...
New

Other popular topics Top

albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID&lt;0.412.0&gt; terminating ** (Postgrex.Error) FATAL...
New
johnnyicon
Hi all, I’ve just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I’m trying to use Postgres...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
Emily
I have VueJS GUIs with the project generated using Webpack. I have Elixir modules that will need to be used by the VueJS GUIs. I forese...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
marick
I had some trouble figuring out how to make many-to-many associations work. Once I got it working, I wrote a blog post. Because I’m a nov...
New
AstonJ
Seen any cool LiveView demos, sample apps or examples? Please post them here! :003:
New
sergio
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
New

We're in Beta

About us Mission Statement