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

Cleaner Pid observable code #12702

Merged
merged 2 commits into from
Jul 7, 2017

Conversation

kimjoar
Copy link
Contributor

@kimjoar kimjoar commented Jul 7, 2017

The code became simpler when moving the config stuff into the switchMap. Otherwise just some minor cleanups.

Copy link
Member

@azasypkin azasypkin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

}

// Otherwise we return an observable that writes the pid when
// subscribed to and deletes it when unsubscribed (e.g. if new config
// is received or if `stop` is called below.)

return new Observable<PidFile | void>(observable => {
return new Observable(observable => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: observable argument is not used, so we can get rid of it.

.switchMap(config => {
if (config === undefined) {
// If there is no pid config we return an observable that does nothing
return new Observable(noop);
}

// Otherwise we return an observable that writes the pid when
// subscribed to and deletes it when unsubscribed (e.g. if new config
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: does e.g. if new config is received mean I can change pid file path on-the-fly and old file will be deleted and new one created? Is it supposed to work at the moment (didn't manage to see that behaviour)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, it's doing that now:

screen shot 2017-07-07 at 18 09 41

I added some newlines here, and performed the sighup in another window. But just change the config, then sighup the process (kill -1 it), and it should re-apply the config. I specified logging.level: debug first in the kibana config to see the debug logs.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then sighup the process (kill -1 it)

Ah, that the reason, I didn't do that (for some reason I thought we watch the config file for changes all the time), thanks :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Watching is "less safe" as you can be in intermediate states when it triggers. E.g. if you're moving stuff around in the config and hit save at some point (e.g. my IDE that saves whenever I cmd-tab away). It's better to let the user actively notify that the config is ready.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree

@kimjoar kimjoar merged commit d287ca9 into elastic:new-platform Jul 7, 2017
@kimjoar kimjoar deleted the platform/pid-cleanups branch July 7, 2017 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants