[erlang-questions] Setting up a startup service

Jesper Louis Andersen jesper.louis.andersen@REDACTED
Tue Dec 19 14:52:22 CET 2017


Alternatively, you can try using the `forking` type in systemd and then set
up things as it were a forking process. But maybe that won't pan out too
well? It would be what I would try if possible. OTOH, it looks like most
other services are going the `simple` route nowadays, so perhaps it is
better to cater for that setup variant.


On Tue, Dec 19, 2017 at 12:21 AM Ryan Auger <raugerfacebook@REDACTED>
wrote:

> This was it. Thank you Fred.
>
> On Dec 18, 2017, 6:18 PM -0500, Fred Youhanaie <fly@REDACTED>, wrote:
>
> 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
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20171219/b9edb91f/attachment.htm>


More information about the erlang-questions mailing list