<div dir="ltr">Thanks Reindl for replying. <div><br></div><div>Can we make use of the <font face="courier new, monospace">watchdog</font> & <span style="background-color:rgb(249,242,244);font-family:Menlo,Monaco,Consolas,"Courier New",monospace;font-size:12.6px"><font color="#000000">systemd-notify</font></span><span style="background-color:rgb(249,242,244);color:rgb(199,37,78);font-family:Menlo,Monaco,Consolas,"Courier New",monospace;font-size:12.6px"> </span>functionality of systemd? I mean something like this. </div><div><br></div><div><font face="courier new, monospace">[Unit]<br>Description=Test service<br>After=network.target<br><br>[Service]<br>Type=notify</font></div><div><font face="courier new, monospace"># test.sh wrapper script to call the service<br>ExecStart=/opt/test/test.sh<br>Restart=always<br>RestartSec=1<br>TimeoutSec=5<br>WatchdogSec=5<br><br>[Install]<br>WantedBy=multi-user.target</font><br></div><div><br></div><div>Then in <font face="courier new, monospace">test.sh</font> can we do something like </div><div><br></div><div><font face="courier new, monospace">#!/bin/bash<br>trap 'kill $(jobs -p)' EXIT</font></div><div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace"># Start the actual service<br>/opt/test/service &<br>PID=$!<br><br>/bin/systemd-notify --ready<br>while(true); do<br> FAIL=0<br> kill -0 $PID<br> if [[ $? -ne 0 ]]; then FAIL=1; fi<br><br># curl <a href="http://localhost/test/">http://localhost/test/</a><br># if [[ $? -ne 0 ]]; then FAIL=1; fi<br><br>if [[ $FAIL -eq 0 ]]; then /bin/systemd-notify WATCHDOG=1; fi<br><br> sleep 1<br>done</font><br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Jul 26, 2019 at 12:27 AM Reindl Harald <<a href="mailto:h.reindl@thelounge.net">h.reindl@thelounge.net</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
<br>
Am 25.07.19 um 20:38 schrieb Debraj Manna:<br>
> I have a service on a Ubuntu 16.04 which I use systemctl start, stop,<br>
> restart and status to control.<br>
> <br>
> One time the systemctl status returned active, but the application<br>
> "behind" the service responded http code different from 200.<br>
> <br>
> So I would like to restart the service when the http code is not 200.<br>
> Can some one let me know is there a way to achieve the same via systemd? <br>
<br>
nope, just write a seperate service with a little curl magic and<br>
"systemctl condrestart" and remember that you have to avoid premature<br>
restarts just because of a little load peak<br>
_______________________________________________<br>
systemd-devel mailing list<br>
<a href="mailto:systemd-devel@lists.freedesktop.org" target="_blank">systemd-devel@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/systemd-devel" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/systemd-devel</a></blockquote></div>