@Test public void testCPInRunCommand() { run = new RunCommand(); run.setExecutionContext(new ExecutionContext(run, null, null)); run.setClasspath("." + File.pathSeparator + "target/externals"); run.setMainVerticle(VERTICLE); run.setInstances(1); run.run(); assertWaitUntil(() -> { try { return getHttpCode() == 200; } catch (IOException e) { return false; } }); }
public void run() { shutdownRedeployment(); } });
public void run() { if (redeploy == null || redeploy.isEmpty()) { JsonObject conf = getConfiguration(); if (conf == null) { conf = new JsonObject(); afterConfigParsed(conf); ((VertxInternal) vertx).addCloseHook(completionHandler -> { try { beforeStoppingVertx(vertx); completionHandler.handle(Future.succeededFuture()); } catch (Exception e) { configureFromSystemProperties(deploymentOptions, DEPLOYMENT_OPTIONS_PROP_PREFIX); deploymentOptions.setConfig(conf).setWorker(worker).setHa(ha).setInstances(instances); beforeDeployingVerticle(deploymentOptions); deploy(); } else { initializeRedeployment();
protected void deploy() { deploy(mainVerticle, vertx, deploymentOptions, res -> { if (res.failed()) { res.cause().printStackTrace(); handleDeployFailed(res.cause()); } }); }
@After public void tearDown() throws InterruptedException { super.tearDown(); final RunCommand run = (RunCommand) cli.getExistingCommandInstance("run"); if (run != null) { Vertx vertx = run.vertx; close(vertx); run.stopBackgroundApplication(null); run.shutdownRedeployment(); } FakeClusterManager.reset(); waitForTermination(); }
/** * Sets the main verticle that is deployed. * * @param verticle the verticle */ @Override @Argument(index = 0, argName = "main-verticle", required = false) @DefaultValue("js:>") @Description("The main verticle to deploy, it can be a script file or a package directory.") public void setMainVerticle(String verticle) { if (!verticle.contains(":")) { super.setMainVerticle("js:" + verticle); } else { super.setMainVerticle(verticle); } }
/** * Initializes the redeployment cycle. In "redeploy mode", the application is launched as background, and is * restarted after every change. A {@link Watcher} instance is responsible for monitoring files and triggering the * redeployment. */ protected synchronized void initializeRedeployment() { if (watcher != null) { throw new IllegalStateException("Redeployment already started ? The watcher already exists"); } // Compute the application id. We append "-redeploy" to ease the identification in the process list. vertxApplicationBackgroundId = UUID.randomUUID().toString() + "-redeploy"; watcher = new Watcher(getCwd(), redeploy, this::startAsBackgroundApplication, // On deploy this::stopBackgroundApplication, // On undeploy onRedeployCommand, // In between command redeployGracePeriod, // The redeploy grace period redeployScanPeriod); // The redeploy scan period // Close the watcher when the JVM is terminating. // Notice that the vert.x finalizer is not registered when we run in redeploy mode. Runtime.getRuntime().addShutdownHook(new Thread() { public void run() { shutdownRedeployment(); } }); // Start the watching process, it triggers the initial deployment. watcher.watch(); }
@After public void tearDown() throws InterruptedException { super.tearDown(); final RunCommand run = (RunCommand) cli.getExistingCommandInstance("run"); if (run != null) { Vertx vertx = run.vertx; close(vertx); run.stopBackgroundApplication(null); run.shutdownRedeployment(); } FakeClusterManager.reset(); waitForTermination(); }
protected void deploy() { deploy(mainVerticle, vertx, deploymentOptions, res -> { if (res.failed()) { res.cause().printStackTrace(); handleDeployFailed(res.cause()); } }); }
/** * Initializes the redeployment cycle. In "redeploy mode", the application is launched as background, and is * restarted after every change. A {@link Watcher} instance is responsible for monitoring files and triggering the * redeployment. */ protected synchronized void initializeRedeployment() { if (watcher != null) { throw new IllegalStateException("Redeployment already started ? The watcher already exists"); } // Compute the application id. We append "-redeploy" to ease the identification in the process list. vertxApplicationBackgroundId = UUID.randomUUID().toString() + "-redeploy"; watcher = new Watcher(getCwd(), redeploy, this::startAsBackgroundApplication, // On deploy this::stopBackgroundApplication, // On undeploy onRedeployCommand, // In between command redeployGracePeriod, // The redeploy grace period redeployScanPeriod); // The redeploy scan period // Close the watcher when the JVM is terminating. // Notice that the vert.x finalizer is not registered when we run in redeploy mode. Runtime.getRuntime().addShutdownHook(new Thread() { public void run() { shutdownRedeployment(); } }); // Start the watching process, it triggers the initial deployment. watcher.watch(); }
@Test public void testCPInRunCommand() { run = new RunCommand(); run.setExecutionContext(new ExecutionContext(run, null, null)); run.setClasspath("." + File.pathSeparator + "target/externals"); run.setMainVerticle(VERTICLE); run.setInstances(1); run.run(); assertWaitUntil(() -> { try { return getHttpCode() == 200; } catch (IOException e) { return false; } }); }
public void run() { if (redeploy == null || redeploy.isEmpty()) { JsonObject conf = getConfiguration(); if (conf == null) { conf = new JsonObject(); afterConfigParsed(conf); ((VertxInternal) vertx).addCloseHook(completionHandler -> { try { beforeStoppingVertx(vertx); completionHandler.handle(Future.succeededFuture()); } catch (Exception e) { configureFromSystemProperties(deploymentOptions, DEPLOYMENT_OPTIONS_PROP_PREFIX); deploymentOptions.setConfig(conf).setWorker(worker).setHa(ha).setInstances(instances); beforeDeployingVerticle(deploymentOptions); deploy(); } else { initializeRedeployment();
public void run() { shutdownRedeployment(); } });