How to let filebeat process exit when service is stopped?

my service writes to stdin every some seconds.
If I stop service, thus stdin is closed, but filebeat process still works.
I hope when stopping my service, filebeat stops its process also.
How can I do that? many thanks.

filebeat's once flag don't work. because I have many EOFs when my service running.

filebeat version : 5.4

filebeat.prospectors:

  • input_type: stdin
    paths:
    • "-"
      close_eof: true
      fields:
      mesos_log_stream: stdin
      output.logstash:
      hosts: ["test.com:23121"]

have you tried to run filebeat with -once flag? You might want configure shutdown_timeout, giving filebeat a chance to publish the events though.

I have tried once flag.
but EOF is different from stdin has been closed.
If my service will output many EOFs, then old filebeat process will be stopped, new process starts over and over when
my service is still on.

what I hope is as follows:
when my service is stopped, stdin is closed, filebeat will be closed then.

home come you script can close stdout multiple times?

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