# Deb package stop service

**URL:** <https://discuss.elastic.co/t/deb-package-stop-service/8889>\
**Category:** Elasticsearch\
**Created:** [August 29, 2012, 10:51pm UTC](https://discuss.elastic.co/t/deb-package-stop-service/8889 "2012-08-29T22:51:50Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Onilton\_Maciel](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/onilton_maciel/32/2500_2.png) [@Onilton\_Maciel](https://discuss.elastic.co/u/Onilton_Maciel)\
**Post date:** [August 29, 2012, 10:51pm UTC](https://discuss.elastic.co/t/deb-package-stop-service/8889/1 "2012-08-29T22:51:50Z")

</div>

Can anyone tell me if in the daemon script of elasticsearch in the deb  
package do the "stop" option works like it's done when I perform a kill?

I worried about this, because almost everytime I use kill to terminate  
elasticsearch, I come back with a missing shard. =/

I am talking about a hard install of elastic search (without deb package)

To everything work as expected when I bring the clusters back, I have to  
perform an API shutdown in all nodes (I do a flush before it, but just to  
make sure, I don't think it's necessary)

[http://www.elasticsearch.org/guide/reference/api/admin-cluster-nodes-shutdown.html](http://www.elasticsearch.org/guide/reference/api/admin-cluster-nodes-shutdown.html)

And then everything works fine when I start the nodes again.

But if kill any (or all) of the nodes, I usually get a missing shard when I  
bring the cluster back.

I investigated a little bit in the /etc/init.d/elasticsearch script and  
stop doesn't seem to do that:

stop)  
log\_daemon\_msg "Stopping $DESC"

```
    set +e
    if [-f "$PID_FILE"]; then
            start-stop-daemon --stop --pidfile "$PID_FILE" \
                    --user "$ES_USER" \
                    --retry=TERM/20/KILL/5 >/dev/null
            if [$? -eq 1]; then
                    log_progress_msg "$DESC is not running but pid file

```

exists, cleaning up"  
elif [$? -eq 3]; then  
PID="`cat $PID_FILE`"  
log\_failure\_msg "Failed to stop $DESC (pid $PID)"  
exit 1  
fi  
rm -f "$PID\_FILE"  
else  
log\_progress\_msg "(not running)"  
fi  
log\_end\_msg 0  
set -e

--

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [August 30, 2012, 4:46am UTC](https://discuss.elastic.co/t/deb-package-stop-service/8889/2 "2012-08-30T04:46:25Z")

</div>

With which option do you kill ES node?  
-9 ?  
-5 ?

--  
David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 30 août 2012 à 00:51, Onilton Maciel [oniltonmaciel@gmail.com](mailto:oniltonmaciel@gmail.com) a écrit :

> Can anyone tell me if in the daemon script of elasticsearch in the deb package do the "stop" option works like it's done when I perform a kill?
> 
> I worried about this, because almost everytime I use kill to terminate elasticsearch, I come back with a missing shard. =/
> 
> I am talking about a hard install of Elasticsearch (without deb package)
> 
> To everything work as expected when I bring the clusters back, I have to perform an API shutdown in all nodes (I do a flush before it, but just to make sure, I don't think it's necessary)
> 
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/admin-cluster-nodes-shutdown.html)
> 
> And then everything works fine when I start the nodes again.
> 
> But if kill any (or all) of the nodes, I usually get a missing shard when I bring the cluster back.
> 
> I investigated a little bit in the /etc/init.d/elasticsearch script and stop doesn't seem to do that:
> 
> stop)  
> log\_daemon\_msg "Stopping $DESC"
> 
> ```
> set +e
> if [-f "$PID_FILE"]; then
> start-stop-daemon --stop --pidfile "$PID_FILE" \
> --user "$ES_USER" \
> --retry=TERM/20/KILL/5 >/dev/null
> if [$? -eq 1]; then
> log_progress_msg "$DESC is not running but pid file exists, cleaning up"
> elif [$? -eq 3]; then
> PID="`cat $PID_FILE`"
> log_failure_msg "Failed to stop $DESC (pid $PID)"
> exit 1
> fi
> rm -f "$PID_FILE"
> else
> log_progress_msg "(not running)"
> fi
> log_end_msg 0
> set -e
> 
> ```
> 
> --

--

---

<div class="post-metadata">

**Author:** ![Onilton\_Maciel](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/onilton_maciel/32/2500_2.png) [@Onilton\_Maciel](https://discuss.elastic.co/u/Onilton_Maciel)\
**Post date:** [August 30, 2012, 11:00am UTC](https://discuss.elastic.co/t/deb-package-stop-service/8889/3 "2012-08-30T11:00:23Z")

</div>

I don't remember right now.

But first I usually (when killing programas) send an killall (that a think  
that sends a SIGTERM)

And then, if it does not terminate the thing, I usually send a SIGKILL.

BTW, I think this is sort of what what it is done by the init.d script.

On Thu, Aug 30, 2012 at 12:46 AM, David Pilato [david@pilato.fr](mailto:david@pilato.fr) wrote:

> With which option do you kill ES node?  
> -9 ?  
> -5 ?
> 
> --  
> David 😉  
> Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> 
> Le 30 août 2012 à 00:51, Onilton Maciel [oniltonmaciel@gmail.com](mailto:oniltonmaciel@gmail.com) a  
> écrit :
> 
> Can anyone tell me if in the daemon script of elasticsearch in the deb  
> package do the "stop" option works like it's done when I perform a kill?
> 
> I worried about this, because almost everytime I use kill to terminate  
> elasticsearch, I come back with a missing shard. =/
> 
> I am talking about a hard install of Elasticsearch (without deb package)
> 
> To everything work as expected when I bring the clusters back, I have to  
> perform an API shutdown in all nodes (I do a flush before it, but just to  
> make sure, I don't think it's necessary)
> 
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/admin-cluster-nodes-shutdown.html)
> 
> And then everything works fine when I start the nodes again.
> 
> But if kill any (or all) of the nodes, I usually get a missing shard when  
> I bring the cluster back.
> 
> I investigated a little bit in the /etc/init.d/elasticsearch script and  
> stop doesn't seem to do that:
> 
> stop)  
> log\_daemon\_msg "Stopping $DESC"
> 
> ```
> set +e
> if [-f "$PID_FILE"]; then
> start-stop-daemon --stop --pidfile "$PID_FILE" \
> --user "$ES_USER" \
> --retry=TERM/20/KILL/5 >/dev/null
> if [$? -eq 1]; then
> log_progress_msg "$DESC is not running but pid
> 
> ```
> 
> file exists, cleaning up"  
> elif [$? -eq 3]; then  
> PID="`cat $PID_FILE`"  
> log\_failure\_msg "Failed to stop $DESC (pid $PID)"  
> exit 1  
> fi  
> rm -f "$PID\_FILE"  
> else  
> log\_progress\_msg "(not running)"  
> fi  
> log\_end\_msg 0  
> set -e
> 
> --
> 
> --

--

---

<div class="post-metadata">

**Author:** ![Onilton\_Maciel](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/onilton_maciel/32/2500_2.png) [@Onilton\_Maciel](https://discuss.elastic.co/u/Onilton_Maciel)\
**Post date:** [August 30, 2012, 11:04am UTC](https://discuss.elastic.co/t/deb-package-stop-service/8889/4 "2012-08-30T11:04:00Z")

</div>

Another info, SIGINT seems to cause the same problems of SIGKILL. But a  
think SIGINT can be catch by the program, unlike SIGKILL.

So it would be nice if elasticsearch did some handling for the SIGINT  
signal.

On Thu, Aug 30, 2012 at 7:00 AM, Onilton Maciel [oniltonmaciel@gmail.com](mailto:oniltonmaciel@gmail.com)wrote:

> I don't remember right now.
> 
> But first I usually (when killing programas) send an killall (that a think  
> that sends a SIGTERM)
> 
> And then, if it does not terminate the thing, I usually send a SIGKILL.
> 
> BTW, I think this is sort of what what it is done by the init.d script.
> 
> On Thu, Aug 30, 2012 at 12:46 AM, David Pilato [david@pilato.fr](mailto:david@pilato.fr) wrote:
> 
> > With which option do you kill ES node?  
> > -9 ?  
> > -5 ?
> > 
> > --  
> > David 😉  
> > Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> > 
> > Le 30 août 2012 à 00:51, Onilton Maciel [oniltonmaciel@gmail.com](mailto:oniltonmaciel@gmail.com) a  
> > écrit :
> > 
> > Can anyone tell me if in the daemon script of elasticsearch in the deb  
> > package do the "stop" option works like it's done when I perform a kill?
> > 
> > I worried about this, because almost everytime I use kill to terminate  
> > elasticsearch, I come back with a missing shard. =/
> > 
> > I am talking about a hard install of Elasticsearch (without deb package)
> > 
> > To everything work as expected when I bring the clusters back, I have to  
> > perform an API shutdown in all nodes (I do a flush before it, but just to  
> > make sure, I don't think it's necessary)
> > 
> > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/admin-cluster-nodes-shutdown.html)
> > 
> > And then everything works fine when I start the nodes again.
> > 
> > But if kill any (or all) of the nodes, I usually get a missing shard when  
> > I bring the cluster back.
> > 
> > I investigated a little bit in the /etc/init.d/elasticsearch script and  
> > stop doesn't seem to do that:
> > 
> > stop)  
> > log\_daemon\_msg "Stopping $DESC"
> > 
> > ```
> > set +e
> > if [-f "$PID_FILE"]; then
> > start-stop-daemon --stop --pidfile "$PID_FILE" \
> > --user "$ES_USER" \
> > --retry=TERM/20/KILL/5 >/dev/null
> > if [$? -eq 1]; then
> > log_progress_msg "$DESC is not running but pid
> > 
> > ```
> > 
> > file exists, cleaning up"  
> > elif [$? -eq 3]; then  
> > PID="`cat $PID_FILE`"  
> > log\_failure\_msg "Failed to stop $DESC (pid $PID)"  
> > exit 1  
> > fi  
> > rm -f "$PID\_FILE"  
> > else  
> > log\_progress\_msg "(not running)"  
> > fi  
> > log\_end\_msg 0  
> > set -e
> > 
> > --
> > 
> > --

--

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [August 30, 2012, 11:31am UTC](https://discuss.elastic.co/t/deb-package-stop-service/8889/5 "2012-08-30T11:31:13Z")

</div>

I never lose a shard when I killed ES or used the service elasticsearch stop command.

I don't understand why you have a missing shard each time.

--  
David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 30 août 2012 à 13:04, Onilton Maciel [oniltonmaciel@gmail.com](mailto:oniltonmaciel@gmail.com) a écrit :

> Another info, SIGINT seems to cause the same problems of SIGKILL. But a think SIGINT can be catch by the program, unlike SIGKILL.
> 
> So it would be nice if elasticsearch did some handling for the SIGINT signal.
> 
> On Thu, Aug 30, 2012 at 7:00 AM, Onilton Maciel [oniltonmaciel@gmail.com](mailto:oniltonmaciel@gmail.com) wrote:  
> I don't remember right now.
> 
> But first I usually (when killing programas) send an killall (that a think that sends a SIGTERM)
> 
> And then, if it does not terminate the thing, I usually send a SIGKILL.
> 
> BTW, I think this is sort of what what it is done by the init.d script.
> 
> On Thu, Aug 30, 2012 at 12:46 AM, David Pilato [david@pilato.fr](mailto:david@pilato.fr) wrote:  
> With which option do you kill ES node?  
> -9 ?  
> -5 ?
> 
> --  
> David 😉  
> Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> 
> Le 30 août 2012 à 00:51, Onilton Maciel [oniltonmaciel@gmail.com](mailto:oniltonmaciel@gmail.com) a écrit :
> 
> > Can anyone tell me if in the daemon script of elasticsearch in the deb package do the "stop" option works like it's done when I perform a kill?
> > 
> > I worried about this, because almost everytime I use kill to terminate elasticsearch, I come back with a missing shard. =/
> > 
> > I am talking about a hard install of Elasticsearch (without deb package)
> > 
> > To everything work as expected when I bring the clusters back, I have to perform an API shutdown in all nodes (I do a flush before it, but just to make sure, I don't think it's necessary)
> > 
> > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/admin-cluster-nodes-shutdown.html)
> > 
> > And then everything works fine when I start the nodes again.
> > 
> > But if kill any (or all) of the nodes, I usually get a missing shard when I bring the cluster back.
> > 
> > I investigated a little bit in the /etc/init.d/elasticsearch script and stop doesn't seem to do that:
> > 
> > stop)  
> > log\_daemon\_msg "Stopping $DESC"
> > 
> > ```
> > set +e
> > if [-f "$PID_FILE"]; then
> > start-stop-daemon --stop --pidfile "$PID_FILE" \
> > --user "$ES_USER" \
> > --retry=TERM/20/KILL/5 >/dev/null
> > if [$? -eq 1]; then
> > log_progress_msg "$DESC is not running but pid file exists, cleaning up"
> > elif [$? -eq 3]; then
> > PID="`cat $PID_FILE`"
> > log_failure_msg "Failed to stop $DESC (pid $PID)"
> > exit 1
> > fi
> > rm -f "$PID_FILE"
> > else
> > log_progress_msg "(not running)"
> > fi
> > log_end_msg 0
> > set -e
> > 
> > ```
> > 
> > --
> 
> --
> 
> --

--

---

<div class="post-metadata">

**Author:** ![Onilton\_Maciel](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/onilton_maciel/32/2500_2.png) [@Onilton\_Maciel](https://discuss.elastic.co/u/Onilton_Maciel)\
**Post date:** [August 30, 2012, 12:36pm UTC](https://discuss.elastic.co/t/deb-package-stop-service/8889/6 "2012-08-30T12:36:44Z")

</div>

I probably used kill -9 (SIGKILL) option when I got the missing shard.

or SIGINT.

Not sure if it's possible to get this error with SIGTERM. (Actually, I  
really don't think so.)

Question: Where you still indexing when you killed ES?

On Thu, Aug 30, 2012 at 7:31 AM, David Pilato [david@pilato.fr](mailto:david@pilato.fr) wrote:

> I never lose a shard when I killed ES or used the service elasticsearch  
> stop command.
> 
> I don't understand why you have a missing shard each time.
> 
> --  
> David 😉  
> Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> 
> Le 30 août 2012 à 13:04, Onilton Maciel [oniltonmaciel@gmail.com](mailto:oniltonmaciel@gmail.com) a  
> écrit :
> 
> Another info, SIGINT seems to cause the same problems of SIGKILL. But a  
> think SIGINT can be catch by the program, unlike SIGKILL.
> 
> So it would be nice if elasticsearch did some handling for the SIGINT  
> signal.
> 
> On Thu, Aug 30, 2012 at 7:00 AM, Onilton Maciel [oniltonmaciel@gmail.com](mailto:oniltonmaciel@gmail.com)wrote:
> 
> > I don't remember right now.
> > 
> > But first I usually (when killing programas) send an killall (that a  
> > think that sends a SIGTERM)
> > 
> > And then, if it does not terminate the thing, I usually send a SIGKILL.
> > 
> > BTW, I think this is sort of what what it is done by the init.d script.
> > 
> > On Thu, Aug 30, 2012 at 12:46 AM, David Pilato [david@pilato.fr](mailto:david@pilato.fr) wrote:
> > 
> > > With which option do you kill ES node?  
> > > -9 ?  
> > > -5 ?
> > > 
> > > --  
> > > David 😉  
> > > Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> > > 
> > > Le 30 août 2012 à 00:51, Onilton Maciel [oniltonmaciel@gmail.com](mailto:oniltonmaciel@gmail.com) a  
> > > écrit :
> > > 
> > > Can anyone tell me if in the daemon script of elasticsearch in the deb  
> > > package do the "stop" option works like it's done when I perform a kill?
> > > 
> > > I worried about this, because almost everytime I use kill to terminate  
> > > elasticsearch, I come back with a missing shard. =/
> > > 
> > > I am talking about a hard install of Elasticsearch (without deb package)
> > > 
> > > To everything work as expected when I bring the clusters back, I have to  
> > > perform an API shutdown in all nodes (I do a flush before it, but just to  
> > > make sure, I don't think it's necessary)
> > > 
> > > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/admin-cluster-nodes-shutdown.html)
> > > 
> > > And then everything works fine when I start the nodes again.
> > > 
> > > But if kill any (or all) of the nodes, I usually get a missing shard  
> > > when I bring the cluster back.
> > > 
> > > I investigated a little bit in the /etc/init.d/elasticsearch script and  
> > > stop doesn't seem to do that:
> > > 
> > > stop)  
> > > log\_daemon\_msg "Stopping $DESC"
> > > 
> > > ```
> > > set +e
> > > if [-f "$PID_FILE"]; then
> > > start-stop-daemon --stop --pidfile "$PID_FILE" \
> > > --user "$ES_USER" \
> > > --retry=TERM/20/KILL/5 >/dev/null
> > > if [$? -eq 1]; then
> > > log_progress_msg "$DESC is not running but pid
> > > 
> > > ```
> > > 
> > > file exists, cleaning up"  
> > > elif [$? -eq 3]; then  
> > > PID="`cat $PID_FILE`"  
> > > log\_failure\_msg "Failed to stop $DESC (pid $PID)"  
> > > exit 1  
> > > fi  
> > > rm -f "$PID\_FILE"  
> > > else  
> > > log\_progress\_msg "(not running)"  
> > > fi  
> > > log\_end\_msg 0  
> > > set -e
> > > 
> > > --
> > > 
> > > --
> 
> --
> 
> --

--

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [August 30, 2012, 12:44pm UTC](https://discuss.elastic.co/t/deb-package-stop-service/8889/7 "2012-08-30T12:44:11Z")

</div>

No.

--  
David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 30 août 2012 à 14:36, Onilton Maciel [oniltonmaciel@gmail.com](mailto:oniltonmaciel@gmail.com) a écrit :

> I probably used kill -9 (SIGKILL) option when I got the missing shard.
> 
> or SIGINT.
> 
> Not sure if it's possible to get this error with SIGTERM. (Actually, I really don't think so.)
> 
> Question: Where you still indexing when you killed ES?
> 
> On Thu, Aug 30, 2012 at 7:31 AM, David Pilato [david@pilato.fr](mailto:david@pilato.fr) wrote:  
> I never lose a shard when I killed ES or used the service elasticsearch stop command.
> 
> I don't understand why you have a missing shard each time.
> 
> --  
> David 😉  
> Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> 
> Le 30 août 2012 à 13:04, Onilton Maciel [oniltonmaciel@gmail.com](mailto:oniltonmaciel@gmail.com) a écrit :
> 
> > Another info, SIGINT seems to cause the same problems of SIGKILL. But a think SIGINT can be catch by the program, unlike SIGKILL.
> > 
> > So it would be nice if elasticsearch did some handling for the SIGINT signal.
> > 
> > On Thu, Aug 30, 2012 at 7:00 AM, Onilton Maciel [oniltonmaciel@gmail.com](mailto:oniltonmaciel@gmail.com) wrote:  
> > I don't remember right now.
> > 
> > But first I usually (when killing programas) send an killall (that a think that sends a SIGTERM)
> > 
> > And then, if it does not terminate the thing, I usually send a SIGKILL.
> > 
> > BTW, I think this is sort of what what it is done by the init.d script.
> > 
> > On Thu, Aug 30, 2012 at 12:46 AM, David Pilato [david@pilato.fr](mailto:david@pilato.fr) wrote:  
> > With which option do you kill ES node?  
> > -9 ?  
> > -5 ?
> > 
> > --  
> > David 😉  
> > Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> > 
> > Le 30 août 2012 à 00:51, Onilton Maciel [oniltonmaciel@gmail.com](mailto:oniltonmaciel@gmail.com) a écrit :
> > 
> > > Can anyone tell me if in the daemon script of elasticsearch in the deb package do the "stop" option works like it's done when I perform a kill?
> > > 
> > > I worried about this, because almost everytime I use kill to terminate elasticsearch, I come back with a missing shard. =/
> > > 
> > > I am talking about a hard install of Elasticsearch (without deb package)
> > > 
> > > To everything work as expected when I bring the clusters back, I have to perform an API shutdown in all nodes (I do a flush before it, but just to make sure, I don't think it's necessary)
> > > 
> > > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/admin-cluster-nodes-shutdown.html)
> > > 
> > > And then everything works fine when I start the nodes again.
> > > 
> > > But if kill any (or all) of the nodes, I usually get a missing shard when I bring the cluster back.
> > > 
> > > I investigated a little bit in the /etc/init.d/elasticsearch script and stop doesn't seem to do that:
> > > 
> > > stop)  
> > > log\_daemon\_msg "Stopping $DESC"
> > > 
> > > ```
> > > set +e
> > > if [-f "$PID_FILE"]; then
> > > start-stop-daemon --stop --pidfile "$PID_FILE" \
> > > --user "$ES_USER" \
> > > --retry=TERM/20/KILL/5 >/dev/null
> > > if [$? -eq 1]; then
> > > log_progress_msg "$DESC is not running but pid file exists, cleaning up"
> > > elif [$? -eq 3]; then
> > > PID="`cat $PID_FILE`"
> > > log_failure_msg "Failed to stop $DESC (pid $PID)"
> > > exit 1
> > > fi
> > > rm -f "$PID_FILE"
> > > else
> > > log_progress_msg "(not running)"
> > > fi
> > > log_end_msg 0
> > > set -e
> > > 
> > > ```
> > > 
> > > --
> > 
> > --
> > 
> > --
> 
> --
> 
> --

--

---

<div class="post-metadata">

**Author:** ![Onilton\_Maciel](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/onilton_maciel/32/2500_2.png) [@Onilton\_Maciel](https://discuss.elastic.co/u/Onilton_Maciel)\
**Post date:** [August 30, 2012, 12:48pm UTC](https://discuss.elastic.co/t/deb-package-stop-service/8889/8 "2012-08-30T12:48:58Z")

</div>

Question: Where you still indexing when you killed ES?

No.

Ok, so my scenario is a little bit different than yours. =)

So the doubt remains... =/

On Thu, Aug 30, 2012 at 8:44 AM, David Pilato [david@pilato.fr](mailto:david@pilato.fr) wrote:

> No.
> 
> --  
> David 😉  
> Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> 
> Le 30 août 2012 à 14:36, Onilton Maciel [oniltonmaciel@gmail.com](mailto:oniltonmaciel@gmail.com) a  
> écrit :
> 
> I probably used kill -9 (SIGKILL) option when I got the missing shard.
> 
> or SIGINT.
> 
> Not sure if it's possible to get this error with SIGTERM. (Actually, I  
> really don't think so.)
> 
> Question: Where you still indexing when you killed ES?
> 
> On Thu, Aug 30, 2012 at 7:31 AM, David Pilato [david@pilato.fr](mailto:david@pilato.fr) wrote:
> 
> > I never lose a shard when I killed ES or used the service elasticsearch  
> > stop command.
> > 
> > I don't understand why you have a missing shard each time.
> > 
> > --  
> > David 😉  
> > Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> > 
> > Le 30 août 2012 à 13:04, Onilton Maciel [oniltonmaciel@gmail.com](mailto:oniltonmaciel@gmail.com) a  
> > écrit :
> > 
> > Another info, SIGINT seems to cause the same problems of SIGKILL. But a  
> > think SIGINT can be catch by the program, unlike SIGKILL.
> > 
> > So it would be nice if elasticsearch did some handling for the SIGINT  
> > signal.
> > 
> > On Thu, Aug 30, 2012 at 7:00 AM, Onilton Maciel [oniltonmaciel@gmail.com](mailto:oniltonmaciel@gmail.com)wrote:
> > 
> > > I don't remember right now.
> > > 
> > > But first I usually (when killing programas) send an killall (that a  
> > > think that sends a SIGTERM)
> > > 
> > > And then, if it does not terminate the thing, I usually send a SIGKILL.
> > > 
> > > BTW, I think this is sort of what what it is done by the init.d script.
> > > 
> > > On Thu, Aug 30, 2012 at 12:46 AM, David Pilato [david@pilato.fr](mailto:david@pilato.fr) wrote:
> > > 
> > > > With which option do you kill ES node?  
> > > > -9 ?  
> > > > -5 ?
> > > > 
> > > > --  
> > > > David 😉  
> > > > Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> > > > 
> > > > Le 30 août 2012 à 00:51, Onilton Maciel [oniltonmaciel@gmail.com](mailto:oniltonmaciel@gmail.com) a  
> > > > écrit :
> > > > 
> > > > Can anyone tell me if in the daemon script of elasticsearch in the deb  
> > > > package do the "stop" option works like it's done when I perform a kill?
> > > > 
> > > > I worried about this, because almost everytime I use kill to terminate  
> > > > elasticsearch, I come back with a missing shard. =/
> > > > 
> > > > I am talking about a hard install of Elasticsearch (without deb  
> > > > package)
> > > > 
> > > > To everything work as expected when I bring the clusters back, I have  
> > > > to perform an API shutdown in all nodes (I do a flush before it, but just  
> > > > to make sure, I don't think it's necessary)
> > > > 
> > > > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/admin-cluster-nodes-shutdown.html)
> > > > 
> > > > And then everything works fine when I start the nodes again.
> > > > 
> > > > But if kill any (or all) of the nodes, I usually get a missing shard  
> > > > when I bring the cluster back.
> > > > 
> > > > I investigated a little bit in the /etc/init.d/elasticsearch script and  
> > > > stop doesn't seem to do that:
> > > > 
> > > > stop)  
> > > > log\_daemon\_msg "Stopping $DESC"
> > > > 
> > > > ```
> > > > set +e
> > > > if [-f "$PID_FILE"]; then
> > > > start-stop-daemon --stop --pidfile "$PID_FILE" \
> > > > --user "$ES_USER" \
> > > > --retry=TERM/20/KILL/5 >/dev/null
> > > > if [$? -eq 1]; then
> > > > log_progress_msg "$DESC is not running but pid
> > > > 
> > > > ```
> > > > 
> > > > file exists, cleaning up"  
> > > > elif [$? -eq 3]; then  
> > > > PID="`cat $PID_FILE`"  
> > > > log\_failure\_msg "Failed to stop $DESC (pid  
> > > > $PID)"  
> > > > exit 1  
> > > > fi  
> > > > rm -f "$PID\_FILE"  
> > > > else  
> > > > log\_progress\_msg "(not running)"  
> > > > fi  
> > > > log\_end\_msg 0  
> > > > set -e
> > > > 
> > > > --
> > > > 
> > > > --
> > 
> > --
> > 
> > --
> 
> --
> 
> --

--

---

<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:** [July 6, 2017, 3:14am UTC](https://discuss.elastic.co/t/deb-package-stop-service/8889/9 "2017-07-06T03:14:35Z")

</div>


