How to use Commands to run maintenance task only

31 views
Skip to first unread message

Aravindo Wingeier

unread,
Mar 9, 2021, 2:28:35 AM3/9/21
to dropwizard-user
Hi

We have a Dropwizard application that does a lot of things in it's application.run() method. We moved a maintenance task into a command, so it can be run independently and without the full Jetty stack. 

Now I noticed that application.run() is still executed in EnvironmentCommand when running the the new command. What is the best way to avoid executing application.run() when running a command? 

I also doubt if using a Command is a good way to extract functionality? We still need the Configuration, so running a plain java application does not help as well. 

Best regards, 
Aravindo


Ryan Kennedy

unread,
Mar 9, 2021, 10:37:40 AM3/9/21
to dropwiz...@googlegroups.com
Your Application’s run method is being called because you’re using an EnvironmentCommand. EnvironmentCommand calls the run method on your Application to set up the Environment it’s going to pass to you. 

If you only need the Configuration (end not the Environment) make a ConfiguredCommand, instead:


Ryan

--
You received this message because you are subscribed to the Google Groups "dropwizard-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dropwizard-us...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dropwizard-user/f7fdaf3b-8e38-49a9-96dd-dc8078f72c10n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages