[erlang-questions] Setting up a startup service

Fred Youhanaie fly@REDACTED
Tue Dec 19 00:18:42 CET 2017


Hi

systemd doesn't work when programs (services) detach and run in the background.

Try starting it with "foreground" instead of start or console.

Cheers,
Fred


On 18/12/17 22:55, asdf asdf wrote:
> Hello all,
> 
> I have built an Erlang program and created a release using rebar3 release. To run this program, I use the command:
> 
> *./_build/default/rel/program/bin/program start*
> 
> What I would like to do now is have this program start on startup whenever the box boots or whenever the VM crashes. I have to use a RHEL 7 box for this, so I am using systemd. I created a service below:
> 
> *[Unit]*
> *Description=program *
> *After=network.target*
> *
> *
> *[Service]*
> *Type=simple *
> *User=root*
> *ExecStart=/home/root/repos/program/_build/default/rel/program/bin/program start *
> *Restart=on-abort*
> *
> *
> *[Install]
> *
> *WantedBy=multi-user.target *
> 
> 
> This doesn’t work however - I get the following output:
> 
> *Dec 18 17:43:59 localhost.localdomain systemd[1]: Started program.
> *
> *Dec 18 17:43:59 localhost.localdomain systemd[1]: Starting program… *
> 
> (It is odd that it says “started program” followed by “starting program”…)
> 
> Now here is the interesting part - if I switch out “start” with “console” , I get good output - I get the successful start message. But then a crash… :
> 
> *Dec 18 17:45:40 localhost.localdomain program[14167]: 17:45:40.429 [info] Application program started on node 'program@REDACTED'*
> *Dec 18 17:45:40 localhost.localdomain program[14167]: Eshell V8.2.2  (abort with ^G)*
> *Dec 18 17:45:40 localhost.localdomain program 14167]: (program@REDACTED)1> *** Terminating erlang ('program@REDACTED’)*
> 
> This crash is expected though, because I tried to start it in console but it was a background process. My point though is that it starts up, but for some unknown reason it is exiting. On top of that, 
> all of the log files in _build/default/rel/program/log are empty, so I’m not getting any valuable info on why it isn’t starting.
> 
> And to clarify, I have copy/pasted the ExecStart command from the file to the command line and it works when it is run from the command line, so this isn’t a path issue.
> 
> Does anyone have any idea as to what I am doing wrong?
> 
> Thank you in advance.
> 
> 
> 
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
> 



More information about the erlang-questions mailing list