Reputation: 166
I am trying to read command line arguments in vert.x
with javascript as language. Could you please help me on this. For example how to read
arguments(arg1, arg2, arg3)
vertx run example.js arg1 arg2 arg3
Upvotes: 1
Views: 2946
Reputation: 435
Looking for the same solution, I ended up to setting environment variables. I run the verticle with
VXPORT="4444" vertx run -cp xxxxx.jar path.to.MyClass
This is how I achieve: https://mihamina.rktmb.org/2019/06/vertx-command-line-parameters.html
Upvotes: 0
Reputation: 2792
If you start your verticle with with vertx run example.js
then the verticle will be deployed by this class: https://github.com/eclipse/vert.x/blob/master/src/main/java/io/vertx/core/Starter.java
Starter.java
will also parse your command line arguments and deploy your verticle. It is not supported from Starter.java
that the commandline arguments are passed through to the verticle. The supported command line arguments can be seen with vertx run --help
The supported way to pass configuration params to the verticle is the the commandline switch --conf
.
--conf <config> Specifies configuration that should
be provided to the verticle.
<config> should reference either a
text file containing a valid JSON
object which represents the
configuration OR be a JSON string.
The config params can be accessed like this Vertx.currentContext().config().arg1
The documentation how to handle config in javascript is here: http://vertx.io/docs/vertx-core/js/#_passing_configuration_to_a_verticle
Upvotes: 3