For various reasons, I am not running logstash (7.10.1) as a service, but rather invoking it on-demand, in a bash script:
/usr/share/logstash/bin/logstash -f /etc/logstash/conf.d/my_ls.conf &
echo ""
echo "#########################################################"
read -p "Press enter to continue "
It works well, but when finishing to create an elasticsearch index successfully, it always pauses with:
[INFO ] [[main]-pipeline-manager] javapipeline - Pipeline Java execution initialization time {"seconds"=>1.3}
[INFO ] [[main]-pipeline-manager] javapipeline - Pipeline started {"pipeline.id"=>"main"}
[INFO ] [[main]<file] observingtail - START, creating Discoverer, Watch with file and sincedb collections
[INFO ] [Agent thread] agent - Pipelines running {:count=>1, :running_pipelines=>[:main], :non_running_pipelines=>[]}
[INFO ] [Api Webserver] agent - Successfully started Logstash API endpoint {:port=>9600}
In order to make it return to the CLI prompt, I need to run from another SSH terminal the following:
pkill -f logstash
This is of course inconvenient and I am looking for a way to make the bash script prompt with "Press any key to exit".
My problem is that the statements after the logstash invocation (with the &
appended), including the prompt read -p "Press enter to continue"
are displayed before logstash actually starts doing its work and the bash script never exits to the CLI prompt.
What is the proper way to make the bash script prompt with "Press any key to exit" when logstash finishes the index creation?
&
appended), bash never gets to the next statement in the script" – In case of&
I really doubt it. What is the next line of the script? How do you know Bash never gets to it?echo "##########"
line after the the call to logstash is actually being executed, but displayed before the entire logstash output. This confused me. I am going to amend my post to more accurately reflect what actually happens.echo
writes beforelogstash
does.logstash
just to build the indexes and then exit. I found no newer article suggesting that this had changed.