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

Windows: makes elasticsearch.bat more friendly to automated processes #9160

Merged
merged 1 commit into from Jan 12, 2015

Conversation

tlrx
Copy link
Member

@tlrx tlrx commented Jan 6, 2015

When JAVA_HOME is not defined on a Windows platform, a message is printed on standard output and the BAT script is paused until the user press a key. This behavior is not compliant to automated processes where elasticsearch.bat can be executed by another script. This commit adds a new parameter --silent / -s that allow to skip this pause. Also, the error message is directed to standard and error outputs.

Closes #8913

@dadoonet
Copy link
Member

dadoonet commented Jan 6, 2015

Why everything appears as modified? Wondering what are the changes in bin/elasticsearch.in.bat

@dadoonet
Copy link
Member

dadoonet commented Jan 6, 2015

I see... Exit... Still not understanding why git thinks everything is rewritten. Is it a CR LF issue?

@tlrx
Copy link
Member Author

tlrx commented Jan 6, 2015

@dadoonet yep, CR LF. I look at it.

@tlrx
Copy link
Member Author

tlrx commented Jan 6, 2015

@dadoonet thanks, should be correctly encoded now.

@dadoonet
Copy link
Member

dadoonet commented Jan 6, 2015

Much better! :)


IF "!silent!" == "Y" (
SET nopauseonerror=Y
) ELSE (
Copy link
Member

Choose a reason for hiding this comment

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

Wondering what would be the effect if you don't rewrite parameters and keep --silent as an option sent to elasticsearch?

I would probably try only to detect that -s or --silent is activated without removing it. Could this work?

Copy link
Member Author

Choose a reason for hiding this comment

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

Could this work?

No. Unlike Unix script, the args name are not renamed and --silent or -s will be passed to the java exec (and failed).

Copy link
Member

Choose a reason for hiding this comment

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

Ah. It will be seen as a java option?

Copy link
Member

Choose a reason for hiding this comment

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

$ java -silent
Unrecognized option: -silent
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

Copy link
Member Author

Choose a reason for hiding this comment

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

yep

Copy link
Member

Choose a reason for hiding this comment

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

But this is working:

$ java -jar injector.jar -silent

As long as - silent is at the end. Would this work with:

"%JAVA_HOME%\bin\java" %JAVA_OPTS% %ES_JAVA_OPTS% -cp "%ES_CLASSPATH%" "org.elasticsearch.bootstrap.Elasticsearch" %ES_PARAMS% 

Copy link
Member Author

Choose a reason for hiding this comment

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

The option --silent / -s here is intended to avoid pausing when JAVA_HOME or else is not found. What you are suggesting will move the JVM options (think -Des.node.name, -Des.pidfile etc) as program arguments, which is not the same thing.

Copy link
Member

Choose a reason for hiding this comment

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

I did not mean that. Sorry if I was unclear. I was just trying to avoid rewriting users arguments to elasticsearch.bat. So if a user run elasticsearch --silent -Des.cluster.name=toto it will run behind the scene java -cp "%ES_CLASSPATH%" "org.elasticsearch.bootstrap.Elasticsearch" --silent -Des.cluster.name=toto but --silent will be totally ignored by elasticsearch...

Not a big deal to me. Just trying to have less code to maintain :)

Copy link
Member Author

Choose a reason for hiding this comment

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

but --silent will be totally ignored by elasticsearch...

And also all -D properties which will be passed as program argument and not as Java command line options...

Copy link
Member

Choose a reason for hiding this comment

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

I see. So forget all my comments! :)

@dadoonet
Copy link
Member

dadoonet commented Jan 6, 2015

Left a comment. The change looks good to me though I did not test it on a windows machine. If you need me to test it, I can probably do it later this week.

@gmarz
Copy link
Contributor

gmarz commented Jan 8, 2015

Just tested this on my Windows 8.1 machine and it looks good. 👍

@gmarz
Copy link
Contributor

gmarz commented Jan 8, 2015

I wonder though if this should just be the default behavior rather than needing a flag? To me, it's more important that the script be programmable out of the box rather than being "manual friendly".

@tlrx
Copy link
Member Author

tlrx commented Jan 9, 2015

@dadoonet Can you please test it?

@gmarz thanks! I think we must keep the current behavior because many users launch ES with a double-click on Windows.

@tlrx tlrx merged commit 261eb5b into elastic:master Jan 12, 2015
On Windows platforms when JAVA_HOME is not defined, a message is printed on standard output and the bat script is paused until the user press a key. This behavior is not compliant to automated processes where elasticsearch.bat can be executed by another script. This commit adds a new parameter --silent / -s that allow to skip the pause. Also, the error message is directed to standard and error outputs.

 Closes elastic#8913
@clintongormley clintongormley added :Delivery/Packaging RPM and deb packaging, tar and zip archives, shell and batch scripts and removed review labels Mar 19, 2015
@tlrx tlrx deleted the fix/8913 branch January 27, 2017 09:18
@mark-vieira mark-vieira added the Team:Delivery Meta label for Delivery team label Nov 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Delivery/Packaging RPM and deb packaging, tar and zip archives, shell and batch scripts >enhancement Team:Delivery Meta label for Delivery team v1.4.3 v1.5.0 v2.0.0-beta1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pause command in elasticsearch.in.bat not friendly to automated processes
5 participants