When LogStash 5.X windows service STOP, doesn't close Orphan Java processes
In windows LogStash service is created using NSSM.
NSSM takes IO redirection inputs and a flag value which determines how to signal Windows kernel and what to do when the windows service is stopped.
when we set
nssm set logstash AppStopMethodSkip 6
It just sends the signal ^C (ctrl +c ) or stop to the Windows kernel, just like we stop a java process in command prompt using a Ctrl+c. But if the parent process spawns threads then only ^C cannot stop the child processes. Just like windows task manager's kill process tree option, in this case we need to send the WM_CLOSE signal to Windows.
For a NSSM windows service it is done when you set
nssm set logstash AppStopMethodSkip 5
Along, with that you need to pass an additional flag to the logstash arg param. the shutdown_watcher.rb in logstash is a listener to the shutdown event. when logstash spawns many worker processes to send different logs, then the shutdown gets stalled if ay of these worker threads have pending events to send to ElasticSearch. If you set the --pipeline.unsafe_shutdown in logstash arg, then the shutdown_watcher invokes the system.exit(-1) and terminates all workers immediately. But in the process these pending events would be lost.
Comments
Post a Comment