# Anyone using SystemD to ensure Elasticsearch is restarted if it crashes?

**URL:** https://discuss.elastic.co/t/anyone-using-systemd-to-ensure-elasticsearch-is-restarted-if-it-crashes/98080
**Category:** Elasticsearch
**Created:** [August 23, 2017, 1:09pm UTC](https://discuss.elastic.co/t/anyone-using-systemd-to-ensure-elasticsearch-is-restarted-if-it-crashes/98080 "2017-08-23T13:09:04Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![A\_B](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/a_b/32/17104_2.png) [@A\_B](https://discuss.elastic.co/u/A_B)
#### Post date: [August 23, 2017, 1:09pm UTC](https://discuss.elastic.co/t/anyone-using-systemd-to-ensure-elasticsearch-is-restarted-if-it-crashes/98080/1 "2017-08-23T13:09:04Z")

</div>

Hello all,

not sure how good of an idea it is but I'm thinking of adding a few lines to the SystemD unit file for Elasticsearch so the service will automatically restart if it dies.

Something like [Restart](https://www.freedesktop.org/software/systemd/man/systemd.service.html#Restart=)

> ...  
> [Service]  
> ...  
> Restart=always  
> RestartSec=3  
> ...

Is anyone doing this? Looks like you can control the unit file template with **$init\_template** in the Puppet module 🙂

Anyway, any reason **not** to do this?

Cheers,  
AB

---

<div class="post-metadata">

### Author: ![thiago](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thiago/32/32096_2.png) [@thiago](https://discuss.elastic.co/u/thiago)
#### Post date: [August 23, 2017, 1:54pm UTC](https://discuss.elastic.co/t/anyone-using-systemd-to-ensure-elasticsearch-is-restarted-if-it-crashes/98080/2 "2017-08-23T13:54:09Z")

</div>

If a node crashes it is because some catastrophe has happened and it is likely that it will crash again if it restarts. So it's better to be notified by the incident to analyze the cause so the node can come back online again safely (instead of going into an endless restart loop that will do more harm to the cluster then good)

---

<div class="post-metadata">

### Author: ![A\_B](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/a_b/32/17104_2.png) [@A\_B](https://discuss.elastic.co/u/A_B)
#### Post date: [August 23, 2017, 2:06pm UTC](https://discuss.elastic.co/t/anyone-using-systemd-to-ensure-elasticsearch-is-restarted-if-it-crashes/98080/3 "2017-08-23T14:06:44Z")

</div>

Hi Thiago,

thanks for the quick reply 🙂

I thought about that. I should probably spend more time on finding the root cause for my problems. Some sort of OOM issue brought down my 20 node cluster the other day. After the nodes were started again the cluster has been pretty stable for a few days. So a restart "fixed" the problem short term. But the longterm solution is to do the legwork and find the underlying issue...

Will hold off on restarting Elasticsearch automatically then.

Cheers,  
AB

---

<div class="post-metadata">

### Author: ![thiago](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thiago/32/32096_2.png) [@thiago](https://discuss.elastic.co/u/thiago)
#### Post date: [August 23, 2017, 2:14pm UTC](https://discuss.elastic.co/t/anyone-using-systemd-to-ensure-elasticsearch-is-restarted-if-it-crashes/98080/4 "2017-08-23T14:14:08Z")

</div>

In this case, restarting could solve the issue. But what if it makes worse? You can not account for all the failure possibilities, so there is always a chance that restarting will make it worse. Because of this, it's simply better to keep monitoring the cluster and take proper action in case of failure.

---

<div class="post-metadata">

### Author: ![A\_B](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/a_b/32/17104_2.png) [@A\_B](https://discuss.elastic.co/u/A_B)
#### Post date: [August 23, 2017, 3:05pm UTC](https://discuss.elastic.co/t/anyone-using-systemd-to-ensure-elasticsearch-is-restarted-if-it-crashes/98080/5 "2017-08-23T15:05:00Z")

</div>

Thank you Thiago for the advise.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [September 20, 2017, 3:05pm UTC](https://discuss.elastic.co/t/anyone-using-systemd-to-ensure-elasticsearch-is-restarted-if-it-crashes/98080/6 "2017-09-20T15:05:07Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
