erlang and systemd: how to combine without nif

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

erlang and systemd: how to combine without nif

Max Lapshin-2
While migrating to systemd from old good SysV init, I've found that it is a very good idea to speak to this daemon and tell him that my software is alive and ready.


systemd authors offer library for this (and I suppose that they want to see these calls in POSIX and all other OS).

Petr Lemenkov together with other commiters have written wrapper around this C library: https://github.com/systemd/erlang-sd_notify

I was completely against this idea, because I do not want to take nif around library that makes a very simple call, so I've decided to write a code that relies on protocol in this systemd library:



Just drop this file to your source, add systemd as a permanent worker for keepalive to work and don't forget to call systemd:ready to commit start.


Service file may look like this:



[Unit]
Description=Retroview
After=network-online.target
Wants=network-online.target

[Service]
Environment=HOME=/var/lib/retroview
Environment=PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin
Environment=LANG=C
Environment=PROCNAME=retroview
Type=notify
User=root
Group=root
LimitNOFILE=102400
ExecStartPre=/bin/mkdir -p /var/lib/retroview
ExecStartPre=/bin/mkdir -p /var/log/retroview
ExecStart=/usr/bin/erl -p /opt/retroview/ebin -noinput -name [hidden email] -s retroview
Restart=on-failure
TimeoutStartSec=300s
WatchdogSec=120
WorkingDirectory=/opt/retroview
NotifyAccess=main

[Install]
WantedBy=multi-user.target


_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: erlang and systemd: how to combine without nif

Benoit Chesneau-2
nice one. Thanks!

benoît

On Wed, Jul 25, 2018 at 12:38 PM Max Lapshin <[hidden email]> wrote:
While migrating to systemd from old good SysV init, I've found that it is a very good idea to speak to this daemon and tell him that my software is alive and ready.


systemd authors offer library for this (and I suppose that they want to see these calls in POSIX and all other OS).

Petr Lemenkov together with other commiters have written wrapper around this C library: https://github.com/systemd/erlang-sd_notify

I was completely against this idea, because I do not want to take nif around library that makes a very simple call, so I've decided to write a code that relies on protocol in this systemd library:



Just drop this file to your source, add systemd as a permanent worker for keepalive to work and don't forget to call systemd:ready to commit start.


Service file may look like this:



[Unit]
Description=Retroview
After=network-online.target
Wants=network-online.target

[Service]
Environment=HOME=/var/lib/retroview
Environment=PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin
Environment=LANG=C
Environment=PROCNAME=retroview
Type=notify
User=root
Group=root
LimitNOFILE=102400
ExecStartPre=/bin/mkdir -p /var/lib/retroview
ExecStartPre=/bin/mkdir -p /var/log/retroview
ExecStart=/usr/bin/erl -p /opt/retroview/ebin -noinput -name [hidden email] -s retroview
Restart=on-failure
TimeoutStartSec=300s
WatchdogSec=120
WorkingDirectory=/opt/retroview
NotifyAccess=main

[Install]
WantedBy=multi-user.target

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions