/** * 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(); }
@Before public void prepare() { root = new File("target/junk/watcher"); deleteRecursive(root); root.mkdirs(); deploy = new AtomicInteger(); undeploy = new AtomicInteger(); watcher = new Watcher(root, Collections.unmodifiableList( Arrays.asList("**" + File.separator + "*.txt", "windows\\*.win", "unix/*.nix", "FOO.bar")), next -> { deploy.incrementAndGet(); if (next != null) { next.handle(null); } }, next -> { undeploy.incrementAndGet(); if (next != null) { next.handle(null); } }, null, 10, 10); }
@Before public void prepare() { root = new File("target/junk/watcher"); File otherRoot = new File(root.getParentFile(), "abs-test"); deleteRecursive(otherRoot); deleteRecursive(root); otherRoot.mkdirs(); root.mkdirs(); deploy = new AtomicInteger(); undeploy = new AtomicInteger(); watcher = new Watcher(otherRoot, Collections.unmodifiableList( Arrays.asList( root.getAbsolutePath() + File.separator + "**" + File.separator + "*.txt", root.getAbsolutePath() + File.separator + "windows\\*.win", root.getAbsolutePath() + File.separator + "unix/*.nix", root.getAbsolutePath() + File.separator + "FOO.bar")), next -> { deploy.incrementAndGet(); if (next != null) { next.handle(null); } }, next -> { undeploy.incrementAndGet(); if (next != null) { next.handle(null); } }, null, 10, 10); } }
/** * 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(); }
@Before public void prepare() { root = new File("target/junk/watcher"); deleteRecursive(root); root.mkdirs(); deploy = new AtomicInteger(); undeploy = new AtomicInteger(); watcher = new Watcher(root, Collections.unmodifiableList( Arrays.asList("**" + File.separator + "*.txt", "windows\\*.win", "unix/*.nix", "FOO.bar")), next -> { deploy.incrementAndGet(); if (next != null) { next.handle(null); } }, next -> { undeploy.incrementAndGet(); if (next != null) { next.handle(null); } }, null, 10, 10); }
@Before public void prepare() { root = new File("target/junk/watcher"); File otherRoot = new File(root.getParentFile(), "abs-test"); deleteRecursive(otherRoot); deleteRecursive(root); otherRoot.mkdirs(); root.mkdirs(); deploy = new AtomicInteger(); undeploy = new AtomicInteger(); watcher = new Watcher(otherRoot, Collections.unmodifiableList( Arrays.asList( root.getAbsolutePath() + File.separator + "**" + File.separator + "*.txt", root.getAbsolutePath() + File.separator + "windows\\*.win", root.getAbsolutePath() + File.separator + "unix/*.nix", root.getAbsolutePath() + File.separator + "FOO.bar")), next -> { deploy.incrementAndGet(); if (next != null) { next.handle(null); } }, next -> { undeploy.incrementAndGet(); if (next != null) { next.handle(null); } }, null, 10, 10); } }