Elasticsearch doesn't update pid file (and kibana does)

Hi everyone!
I have a setup of the elk stack (I don't use any beats or other members of the elastic stack) that start and stop not via deamon or system ctl, rather directly from the respective bin and scripts.
When I start elastic or kibana, I need to find out what is the PID.

One way to achieve that is to use something like:

ps -ef | grep elasticsearch
ps -ef | grep kibana

The risk is that I assume that there are no folders/other processes with the words grep is looking for.

The second option I tried was to check the PID file. Both kibana and elastic generated PID file in this path ~/deployment/folder/path/logs/elastic(kibana).pid

But I noticed something strange:

Kibana updated its pid whenever I started/stoped it, and the pid was consistent between the first pid finding method and the second one.

In elastic, on the other hand, the pid file was not updated each time, the same number is stored in the file, and the ps method generated the correct pid.

Why does elastic does not update the pid file?
Is there a place I can configure elastic to update the pid file?

I use elastic/kibana v6.2 with the default yml files.

Thanks!

How do you specify the PID directory?

I'm also running the bin scripts directly and specifies the PID file with the -p option like this:

bin/elasticsearch -d -p /some/path/node_name.pid

This works well for me in ES 6.8.

You can get the PIDs of the nodes in an Elasticsearch cluster from its API:

GET /_cat/nodes?h=n,p&v

# n      p
# node-1 45152
# node-0 45150
# node-2 45151
#

GET /_nodes/jvm?filter_path=nodes.*.jvm.pid

# {
#   "nodes": {
#     "libdruUFS8-O9_OCZGSj3Q": {
#       "jvm": {
#         "pid": 45151
#       }
#     },
#     "vc5lpqI-QfeYqyx-H3y3kw": {
#       "jvm": {
#         "pid": 45152
#       }
#     },
#     "JIoOZJ1YTAu9znnrEFOsqQ": {
#       "jvm": {
#         "pid": 45150
#       }
#     }
#   }
# }

You can also use node filters to request the PIDs of a filtered set of nodes, for instance the _local node only:

GET /_nodes/_local/jvm?filter_path=nodes.*.jvm.pid

# {
#   "nodes": {
#     "JIoOZJ1YTAu9znnrEFOsqQ": {
#       "jvm": {
#         "pid": 45150
#       }
#     }
#   }
# }

OK great, I will try that, but is there any way to just configure elastic to work with the pid file? Seems alot easier...

I read that on the elastic docs, but for some reason, no file is generated. Plus, I would need to run this script every time I start elastic, and I would rather that elastic will handle this automaticly.

I tried adding this to my elasticsearch.yml:

pidfile: /path/to/pidfile

With this setting, the file was created anew with the correct contents each time Elasticsearch was started, and removed when Elasticsearch stopped. I was using 7.3.0 but this looks to be quite an old feature.

1 Like

It works.
Thanks to you and to @Bernt_Rostad for you time

1 Like

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