Top Description Fields Constructors Methods
io.vertx.core.impl.launcher.commands

public Class RunCommand

extends BareCommand
implements Closeable
Class Inheritance
All Implemented Interfaces
io.vertx.core.Closeable
Annotations
@Name:run
@Summary:Runs a verticle called in its own instance of vert.x.
Imports
io.vertx.core.*, io.vertx.core.cli.CLIException, .CommandLine, io.vertx.core.cli.annotations.*, io.vertx.core.impl.VertxInternal, io.vertx.core.impl.launcher.VertxLifecycleHooks, io.vertx.core.json.JsonObject, io.vertx.core.spi.launcher.ExecutionContext, java.io.File, java.util.ArrayList, .List, .UUID, java.util.stream.Collectors

The vert.x run command that lets you execute verticles.
Author
Clement Escoffier

Field Summary

Modifier and TypeField and Description
protected boolean
protected String
protected DeploymentOptions
protected boolean
protected int
protected String
protected String
protected List<String>
private long
private long
private long
protected String
protected Watcher
protected boolean
Inherited from io.vertx.core.impl.launcher.commands.BareCommand:
clusterHostclusterPortclusterPublicHostclusterPublicPortDEPLOYMENT_OPTIONS_PROP_PREFIXfinalActionhaGroupMETRICS_OPTIONS_PROP_PREFIXoptionsquorumvertxVERTX_EVENTBUS_PROP_PREFIXVERTX_OPTIONS_PROP_PREFIXvertxOptions

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected void
afterConfigParsed(JsonObject config)
References Deprecated JsonObject is deprecated or references (maybe indirectly) at least one deprecated element.

protected void
protected void
protected void
public void
close(Promise<Void>
the promise to signal when close has completed
completion
)

Implements io.vertx.core.Closeable.close.

Close this resource, the completion promise must be notified when the operation has completed.

protected void
protected JsonObject
getConfiguration()
References Deprecated JsonObject is deprecated or references (maybe indirectly) at least one deprecated element.

public boolean
private void
protected synchronized void
initializeRedeployment()

Initializes the redeployment cycle.

public boolean

Returns:

whether the cluster option or the ha option are enabled. Also true when a custom launcher modifies the Vert.x options to set `clustered` to true
isClustered
()

Overrides io.vertx.core.impl.launcher.commands.BareCommand.isClustered.

public void
run()

Overrides io.vertx.core.impl.launcher.commands.BareCommand.run.

Implements io.vertx.core.spi.launcher.Command.run.

Starts vert.x and deploy the verticle.

public void
setCluster(boolean
whether or not to start vert.x in clustered mode.
cluster
)

Enables / disables the clustering.

public void
setConfig(String
the configuration
configuration
)

The main verticle configuration, it can be a json file or a json string.

public void
setHighAvailability(boolean
whether or not to enable the HA.
ha
)

Enables / disables the high-availability.

public void
setInstances(int
the number of instances
instances
)

Sets the number of instance of the verticle to create.

public void
setMainVerticle(String
the verticle
verticle
)

Sets the main verticle that is deployed.

public void
public void
setOnRedeployCommandOld(String
the on redeploy command
command
)
Deprecated Use 'on-redeploy' instead. It will be removed in vert.x 3.3

Sets the user command executed during redeployment.

public void
setRedeploy(List<String> redeploy)

public void
public void
setRedeployScanPeriod(long period)

public void
public void
setUp(ExecutionContext
- the execution context
context
)

Overrides io.vertx.core.spi.launcher.DefaultCommand.setUp.

Implements io.vertx.core.spi.launcher.Command.setUp.

Validates the command line parameters.

public void
setWorker(boolean
true to deploy the verticle as worker, false otherwise
worker
)

Whether or not the verticle is deployed as a worker verticle.

protected synchronized void
shutdownRedeployment()

Stop the redeployment if started.

protected void
startAsBackgroundApplication(Handler<Void>
an optional on-completion handler. If set it must be invoked at the end of this method.
onCompletion
)

On-Deploy action invoked while redeploying.

protected synchronized void
stopBackgroundApplication(Handler<Void>
an optional on-completion handler. If set it must be invoked at the end of this method.
onCompletion
)

On-Undeploy action invoked while redeploying.

Inherited from io.vertx.core.impl.launcher.commands.BareCommand:
addShutdownHookafterStartingVertxbeforeStartingVertxconfigureFromSystemPropertiescreateVertxBuildergetDefaultAddressgetEventBusOptionsgetEventBusOptionsgetJsonFromFileOrStringgetTerminationRunnablerunsetClusterHostsetClusterPortsetClusterPublicHostsetClusterPublicPortsetExecutionContextsetHAGroupsetQuorumsetVertxOptionsstartVertxvertx

Field Detail

clusterback to summary
protected boolean cluster
configback to summary
protected String config
deploymentOptionsback to summary
protected DeploymentOptions deploymentOptions
haback to summary
protected boolean ha
instancesback to summary
protected int instances
mainVerticleback to summary
protected String mainVerticle
onRedeployCommandback to summary
protected String onRedeployCommand
redeployback to summary
protected List<String> redeploy
redeployGracePeriodback to summary
private long redeployGracePeriod
redeployScanPeriodback to summary
private long redeployScanPeriod
redeployTerminationPeriodback to summary
private long redeployTerminationPeriod
vertxApplicationBackgroundIdback to summary
protected String vertxApplicationBackgroundId
watcherback to summary
protected Watcher watcher
workerback to summary
protected boolean worker

Constructor Detail

RunCommandback to summary
public RunCommand()

Method Detail

afterConfigParsedback to summary
protected void afterConfigParsed(JsonObject config)

References Deprecated

JsonObject is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

afterStoppingVertxback to summary
protected void afterStoppingVertx()
beforeDeployingVerticleback to summary
protected void beforeDeployingVerticle(DeploymentOptions deploymentOptions)
beforeStoppingVertxback to summary
protected void beforeStoppingVertx(Vertx vertx)
closeback to summary
public void close(Promise<Void> completion)

Implements io.vertx.core.Closeable.close.

Doc from io.vertx.core.Closeable.close.

Close this resource, the completion promise must be notified when the operation has completed.

Parameters
completion:Promise<Void>

the promise to signal when close has completed

Annotations
@Override
deployback to summary
protected void deploy()
getConfigurationback to summary
protected JsonObject getConfiguration()

References Deprecated

JsonObject is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

getHAback to summary
public boolean getHA()

Overrides io.vertx.core.impl.launcher.commands.BareCommand.getHA.

Returns:boolean

Doc from io.vertx.core.impl.launcher.commands.BareCommand.getHA.

whether or not the vert.x instance should be launched in high-availability mode. This implementation returns true.

Annotations
@Override
handleDeployFailedback to summary
private void handleDeployFailed(Throwable cause)
initializeRedeploymentback to summary
protected synchronized void initializeRedeployment()

Initializes the redeployment cycle. In "redeploy mode", the application is launched as background, and is restarted after every change. A Watcher instance is responsible for monitoring files and triggering the redeployment.

isClusteredback to summary
public boolean isClustered()

Overrides io.vertx.core.impl.launcher.commands.BareCommand.isClustered.

Returns:boolean

whether the cluster option or the ha option are enabled. Also true when a custom launcher modifies the Vert.x options to set `clustered` to true

Annotations
@Override
runback to summary
public void run()

Overrides io.vertx.core.impl.launcher.commands.BareCommand.run.

Implements io.vertx.core.spi.launcher.Command.run.

Starts vert.x and deploy the verticle.

Annotations
@Override
setClusterback to summary
public void setCluster(boolean cluster)

Enables / disables the clustering.

Parameters
cluster:boolean

whether or not to start vert.x in clustered mode.

Annotations
@Option
longName:cluster
acceptValue:false
flag:true
@Description:If specified then the vert.x instance will form a cluster with any other vert.x instances on the network.
setConfigback to summary
public void setConfig(String configuration)

The main verticle configuration, it can be a json file or a json string.

Parameters
configuration:String

the configuration

Annotations
@Option
longName:conf
argName:config
@Description:Specifies configuration that should be provided to the verticle. should reference either a text file containing a valid JSON object which represents the configuration OR be a JSON string.
setHighAvailabilityback to summary
public void setHighAvailability(boolean ha)

Enables / disables the high-availability.

Parameters
ha:boolean

whether or not to enable the HA.

Annotations
@Option
longName:ha
acceptValue:false
flag:true
@Description:If specified the verticle will be deployed as a high availability (HA) deployment. This means it can fail over to any other nodes in the cluster started with the same HA group.
setInstancesback to summary
public void setInstances(int instances)

Sets the number of instance of the verticle to create.

Parameters
instances:int

the number of instances

Annotations
@Option
longName:instances
argName:instances
@DefaultValue:1
@Description:Specifies how many instances of the verticle will be deployed. Defaults to 1.
setMainVerticleback to summary
public void setMainVerticle(String verticle)

Sets the main verticle that is deployed.

Parameters
verticle:String

the verticle

Annotations
@Argument
index:0
argName:main-verticle
required:true
@Description:The main verticle to deploy, it can be a fully qualified class name or a file.
setOnRedeployCommandback to summary
public void setOnRedeployCommand(String command)
Annotations
@Option
longName:on-redeploy
argName:cmd
@Description:Optional shell command executed when a redeployment is triggered
setOnRedeployCommandOldback to summary
public void setOnRedeployCommandOld(String command)

Deprecated

Use 'on-redeploy' instead. It will be removed in vert.x 3.3

Sets the user command executed during redeployment.

Parameters
command:String

the on redeploy command

Annotations
@Option
longName:onRedeploy
argName:cmd
@Description:Optional shell command executed when a redeployment is triggered (deprecated - will be removed in 3.3, use \'on-redeploy\' instead
@Hidden
@Deprecated
setRedeployback to summary
public void setRedeploy(List<String> redeploy)
Annotations
@Option
longName:redeploy
argName:includes
@Description:Enable automatic redeployment of the application. This option takes a set on includes as parameter indicating which files need to be watched. Patterns are separated by a comma.
@ParsedAsList
setRedeployGracePeriodback to summary
public void setRedeployGracePeriod(long period)
Annotations
@Option
longName:redeploy-grace-period
argName:period
@Description:When redeploy is enabled, this option configures the grace period between 2 redeployments. The time is given in milliseconds. 1000 ms by default.
@DefaultValue:1000
setRedeployScanPeriodback to summary
public void setRedeployScanPeriod(long period)
Annotations
@Option
longName:redeploy-scan-period
argName:period
@Description:When redeploy is enabled, this option configures the file system scanning period to detect file changes. The time is given in milliseconds. 250 ms by default.
@DefaultValue:250
setRedeployStopWaitingTimeback to summary
public void setRedeployStopWaitingTime(long period)
Annotations
@Option
longName:redeploy-termination-period
argName:period
@Description:When redeploy is enabled, this option configures the time waited to be sure that the previous version of the application has been stopped. It is useful on Windows, where the \'terminate\' command may take time to be executed.The time is given in milliseconds. 0 ms by default.
@DefaultValue:0
setUpback to summary
public void setUp(ExecutionContext context) throws CLIException

Overrides io.vertx.core.spi.launcher.DefaultCommand.setUp.

Implements io.vertx.core.spi.launcher.Command.setUp.

Validates the command line parameters.

Parameters
context:ExecutionContext

- the execution context

Annotations
@Override
Exceptions
CLIException:
- validation failed
setWorkerback to summary
public void setWorker(boolean worker)

Whether or not the verticle is deployed as a worker verticle.

Parameters
worker:boolean

true to deploy the verticle as worker, false otherwise

Annotations
@Option
longName:worker
acceptValue:false
@Description:If specified then the verticle is a worker verticle.
shutdownRedeploymentback to summary
protected synchronized void shutdownRedeployment()

Stop the redeployment if started.

startAsBackgroundApplicationback to summary
protected void startAsBackgroundApplication(Handler<Void> onCompletion)

On-Deploy action invoked while redeploying. It just starts the application in background, copying all input parameters. In addition, the vertx application id is set.

Parameters
onCompletion:Handler<Void>

an optional on-completion handler. If set it must be invoked at the end of this method.

stopBackgroundApplicationback to summary
protected synchronized void stopBackgroundApplication(Handler<Void> onCompletion)

On-Undeploy action invoked while redeploying. It just stops the application launched in background.

Parameters
onCompletion:Handler<Void>

an optional on-completion handler. If set it must be invoked at the end of this method.