Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to deploy a dropwizard application

I read some comments about the build of dropwizard applications: [1] "Dropwizard is designed to run as a JAR, not as a WAR file." and [2]"You can't do this. Dropwizard embeds Jetty. You should look into just using Jersey as a standard web application.", so, my questions are:

1 - How to deploy a jar file in a production environment?

2 - How will I manage the service? for example, is there a way to monitor the healthy of the application? if the application falls down how can I restart it again automatically?

[1] How to create a war from dropwizard app? [2] Dropwizard in tomcat container

like image 726
Paulo Luan Avatar asked Oct 02 '14 16:10

Paulo Luan


People also ask

How do I start the Dropwizard example application?

You can now start the Dropwizard Example Application by running java -jar target/dropwizard-example-1.0.0.jar server example.yml Alternatively, you can run the Dropwizard Example Application in your IDE: com.example.helloworld.HelloWorldApplication server example.yml

Does Dropwizard use Jetty HTTP?

Because you can’t be a web application without HTTP, Dropwizard uses the Jetty HTTP library to embed an incredibly tuned HTTP server directly into your project. Instead of handing your application off to a complicated application server, Dropwizard projects have a main method which spins up an HTTP server.

What libraries does Dropwizard use?

The main libraries that it uses are Jetty, Jersey, Jackson, JUnit, and Guava. Furthermore, it uses its own library called Metrics. In this tutorial, we'll learn how to configure and run a simple Dropwizard application.

How do Dropwizard configuration parameters work?

Each Dropwizard application has its own subclass of the Configuration class which specifies environment-specific parameters. These parameters are specified in a YAML configuration file which is deserialized to an instance of your application’s configuration class and validated.


1 Answers

You can use tools like runit or systemd to manage your dropwizard app on Linux. They can do things like make sure it starts when the system starts up, and can help with detecting failures. There is a bit of scripting involved.

You can point a monitoring tool at the healthcheck URL of your app to send alerts when it's down.

For deployment, I prefer to package apps using the system packaging format, .deb (Debian-based systems, including Ubuntu), or .rpm (RedHat based systems). Use the fpm package builder to create it, and include your runit files (or whatever), and scripts to copy the jar file somewhere on the target system. If you have a private package repository, you can put builds of your app into it, and installation becomes a matter of "apt-get install myapp" or "yum install myapp". Otherwise, drop the package onto your target server and run "rpm -i myapp.rpm" or similar.

like image 175
Kief Avatar answered Sep 17 '22 11:09

Kief