<div dir="ltr">nice one. Thanks!<div><br></div><div>benoît</div></div><br><div class="gmail_quote"><div dir="ltr">On Wed, Jul 25, 2018 at 12:38 PM Max Lapshin <<a href="mailto:max.lapshin@gmail.com">max.lapshin@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">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.<div><br></div><div><br></div><div>systemd authors offer library for this (and I suppose that they want to see these calls in POSIX and all other OS).</div><div><br></div><div>Petr Lemenkov together with other commiters have written wrapper around this C library: <a href="https://github.com/systemd/erlang-sd_notify" target="_blank">https://github.com/systemd/erlang-sd_notify</a></div><div><br></div><div>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:</div><div><br></div><div><br></div><div><a href="https://gist.github.com/maxlapshin/01773f0fca706acdcb4acb77d91d78bb" target="_blank">https://gist.github.com/maxlapshin/01773f0fca706acdcb4acb77d91d78bb</a><br></div><div><br></div><div>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.</div><div><br></div><div><br></div><div>Service file may look like this:</div><div><br></div><div><br></div><div><br></div><div><div>[Unit]</div><div>Description=Retroview</div><div>After=network-online.target</div><div>Wants=network-online.target</div><div><br></div><div>[Service]</div><div>Environment=HOME=/var/lib/retroview</div><div>Environment=PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin</div><div>Environment=LANG=C</div><div>Environment=PROCNAME=retroview</div><div>Type=notify</div><div>User=root</div><div>Group=root</div><div>LimitNOFILE=102400</div><div>ExecStartPre=/bin/mkdir -p /var/lib/retroview</div><div>ExecStartPre=/bin/mkdir -p /var/log/retroview</div><div>ExecStart=/usr/bin/erl -p /opt/retroview/ebin -noinput -name <a href="mailto:retroview@127.0.0.1" target="_blank">retroview@127.0.0.1</a> -s retroview</div><div>Restart=on-failure<br></div><div>TimeoutStartSec=300s</div><div>WatchdogSec=120</div><div>WorkingDirectory=/opt/retroview</div><div>NotifyAccess=main</div><div><br></div><div>[Install]</div><div>WantedBy=multi-user.target</div></div><div><br></div></div>
_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" rel="noreferrer" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
</blockquote></div>