monit-general
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to use curl to check if service is down?


From: Anthony Ettinger
Subject: Re: How to use curl to check if service is down?
Date: Mon, 27 Jun 2022 02:04:39 -0700

I’m just hitting the index api page which returns some static json. If the api 
crashes that would not return a 200. Usually systemd restarts it but not 
always. 

- 
Anthony
(408) 656-2473 

> On Jun 26, 2022, at 11:15 PM, Lutz Mader <lutz.mader@freenet.de> wrote:
> 
> Hello Anthony,
> as long as you are sure the http status is 200, you can use this.
> 
>> This is what I have now, but I don't know if its correct:
>> 
>> check host grazily.com with address grazily.com
>>        start program = "/bin/systemctl start grazily-api"
>>        stop program = "/bin/systemctl stop grazily-api"
>> 
>>        if failed
>>                port 443 protocol http and request "/api/1" method GET
>> status != 200
>>        then restart
> 
> Unfortunately, in general you will get some other status codes too, but
> this depends to your application.
> I use an addition "... with timeout 30 seconds retry 5 then" to prevent
> restart problems. And for "ssl" connections you can use "... and
> certificate valid > 30 days ..." too.
> 
> if failed
>   port 443 protocol http and request "/api/1" method GET
>   status != 200
>   with timeout 30 seconds retry 5
>   then restart
> 
> See https://mmonit.com/monit/documentation/monit.html#HTTP
> 
> With regards,
> Lutz
> 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]