Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply changes from configuration file without restarting #4513

Closed
suyograo opened this issue Jan 18, 2016 · 7 comments
Closed

Apply changes from configuration file without restarting #4513

suyograo opened this issue Jan 18, 2016 · 7 comments

Comments

@suyograo
Copy link
Contributor

Today, any config changes made to LS pipeline requires a process restart, which is not ideal. Plan is to implement a feature which would track config file for changes and restart the pipeline (same process) with updated changes. This feature can be enabled in two ways:

  1. Passing a CLI long-form option --auto-reload or with short-form -r. Another option: --reload-interval <seconds> controls how often LS should check the config files for changes.
  2. If you don't start with the CLI option, you can send SIGHUP or kill -1 to signal to LS to reload the config file and restart the pipeline.
bin/logstash -f apache.config --auto-reload

Behaviour:

When Logstash detects a change in config, it stops the current pipeline by stopping all the inputs, and attempts to creates a new pipeline using the updated config. A configuration test is run on the new configuration to make sure everything is good syntax wise. Then a new pipeline is created if there are no errors -- all inputs and outputs can be initialized (e.g. ports open). Once successful, the existing pipeline is swapped with the new pipeline. If there are errors, the old pipeline continues to function as before, and the errors are propagated to the console.

When a config is reloaded, the JVM is not restarted. All of this is in-process

Note that --auto-reload is not available with -e flag which lets users pass in configuration through the CLI.

@suyograo suyograo mentioned this issue Jan 18, 2016
2 tasks
@suyograo suyograo changed the title Apply configuration changes from file without restarting Apply changes from configuration file without restarting Jan 21, 2016
@djschny
Copy link

djschny commented Jan 25, 2016

For service oriented apps I wrote in the past that had this behavior, I expanded to include the refreshing from any URL, that way one easy way to get centralized config management was via a web server or similar. For example:

  • file://
  • http://
  • https://
  • ftp://

If you're in Java land, accomplishing this is pretty easy too using something similar to new URL("<my_config_url>").openStream() and regardless of what protocol you're given a stream to read from.

@jsvd
Copy link
Member

jsvd commented Jan 28, 2016

@djschny we support the same in logstash through open-uri https://github.com/elastic/logstash/pull/4520/files#diff-5e1ebf137d1eab8a085fa7c1c4a6fd2cR37
However we're restricting to http/https and file (for no go reason).

@jsvd
Copy link
Member

jsvd commented Feb 5, 2016

merged in master:

Branch Commits
master a90ed32, e38d815, 34ed3c3, 7ee5038, e32f732, 7d8d6e4

I'll open a new PR to add this to 2.x since the branches have greatly diverged

@suyograo
Copy link
Contributor Author

suyograo commented Feb 5, 2016

@jsvd great stuff, keeping this open until its backported to 2.x

@lawre
Copy link

lawre commented Mar 3, 2016

How does the dynamic reload work with systemd service? I perused /etc/sysconfig/logstash and saw no variables corresponding to 'auto_reload' or 'reload_interval'

@jsvd
Copy link
Member

jsvd commented Mar 3, 2016

in #LS_OPTS="" you can set LS_OPTS="-r" to have auto reloading

@jsvd
Copy link
Member

jsvd commented Mar 8, 2016

merged in 2.x

Branch Commits
2.x 0099537

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants