Vert.x 3 Start and Stop command

1,886 views
Skip to first unread message

Abhilash Krishnan

unread,
Jun 25, 2015, 1:28:26 PM6/25/15
to ve...@googlegroups.com
I am using java -jar my-fat.jar to start the <Main-Class>io.vertx.core.Starter</Main-Class>. It is running without any hassles.
Now I want to shutdown the vert.x application by issuing a stop command from CLI. Please let me know how is it possible to achieve?


Clement Escoffier

unread,
Jun 25, 2015, 1:38:39 PM6/25/15
to ve...@googlegroups.com
Hi,

Either by doing a CTRL+C in the same terminal, or by sending a shutdown signal (or kill) to the process.

Clement

On 25 juin 2015 at 19:28:29, Abhilash Krishnan (abhila...@gmail.com) wrote:

I am using java -jar my-fat.jar to start the <Main-Class>io.vertx.core.Starter</Main-Class>. It is running without any hassles.
Now I want to shutdown the vert.x application by issuing a stop command from CLI. Please let me know how is it possible to achieve?


--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Abhilash Krishnan

unread,
Jun 25, 2015, 1:45:24 PM6/25/15
to ve...@googlegroups.com
That is not an elegant way to stop the application since I may have routine tasks to complete or shutdown gracefully. Does have a shutdown hook kind of implementation in it's HTTP/Websocket server implementation.

--
You received this message because you are subscribed to a topic in the Google Groups "vert.x" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/vertx/bCVZAvkoIk8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to vertx+un...@googlegroups.com.

Paulo Lopes

unread,
Jun 25, 2015, 3:30:02 PM6/25/15
to ve...@googlegroups.com
You can add a jvm shutdown hook:

Runtime.getRuntime().addShutdownHook(new Thread() {
    public void run() {
        // clean shutdown here...
    }
});

But you need to do it from your public static void main() method...

Tim Fox

unread,
Jun 26, 2015, 3:11:41 AM6/26/15
to ve...@googlegroups.com
In what way is it "not elegant"?

Vert.x will automatically undeploy any verticles that you deployed, timers you set or handlers that you registered from inside your verticles too.

Clement Escoffier

unread,
Jun 26, 2015, 7:50:42 AM6/26/15
to ve...@googlegroups.com
Hi,

If you want something more “service” (in the linux sense) just have a look on how it’s done in the openshift cartridge (https://github.com/vert-x3/vertx-openshift-cartridge/blob/master/bin/control)

To start just do something like:

    nohup java $VERTX_OPTS -jar $OPENSHIFT_REPO_DIR/application/*.jar $vertx_cluster $RUN_ARGS > $LOG 2>&1 &
    echo $! > ${RUNNING_PID}

and to stop it:

    kill `cat $RUNNING_PID`
    rm $RUNNING_PID


Clement

Robin Coe

unread,
Mar 4, 2018, 6:54:42 AM3/4/18
to vert.x
My experience differs.  I have a very simple verticle that I am running via the maven fabric8 plugin and, while I can send an interrupt signal to the shell and get my prompt back, it doesn't stop the verticle.  Unbeknownst to me, until I had spent several frustrating hours with binding exceptions, I had over 50 JVM processes running, consuming a huge amount of resources.  What I had been doing was releasing the TCP connections, excpecting that to kill the underlying process, but that didn't work.

My implementation is more or less straight out of here, https://github.com/vert-x3/vertx-guide-for-java-devs/blob/master/step-3/src/main/java/io/vertx/guides/wiki/http/HttpServerVerticle.java.  The behaviour is the same from Eclipse and a Cygwin shell.  Could it be a fabric8 bug?  My specific JRE on win10:

$ java -version
java version "1.8.0_111"
Java(TM) SE Runtime Environment (build 1.8.0_111-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.111-b14, mixed mode)

What's interesting is that I learned I could save my code and then one of the runtimes would pick it up.  Consumed all 16G of RAM, though.  But I had to individually kill all the processes.

Clement Escoffier

unread,
Mar 5, 2018, 3:17:50 AM3/5/18
to ve...@googlegroups.com
Hi,

Which windows version are you using? Killing processes on windows does not seem to be very reliable sometimes. 

Clement

Robin Coe

unread,
Mar 14, 2018, 9:53:27 PM3/14/18
to vert.x
Sorry, just saw this response.

I'm running Windows 10 pro, early adopters builds.  At the time of this post, probably build 17115.
Reply all
Reply to author
Forward
0 new messages