quinta-feira, 6 de Julho de 2017 às 19:29:41 UTC-3, Douglas Patriarche 
escreveu:
>
> Please see my responses inline below:
>
> On Wednesday, July 5, 2017 at 6:21:00 PM UTC-4, Flavio Silveira wrote:
>>
>>
>>
>> quarta-feira, 5 de Julho de 2017 às 18:57:22 UTC-3, Douglas Patriarche 
>> escreveu:
>>>
>>> Hi Flavio,
>>>
>>> Yes, that sounds like a sane structure for organizing assets. If you are 
>>> using Maven to manage your project, then your web-visible assets should be 
>>> under the <project>/src/main/resources directory, e.g.:
>>>
>>> <project>/src/main/resources/assets/js
>>> <project>/src/main/resources/assets/css
>>> <project>/src/main/resources/assets/html
>>>
>>>
>>> You can then configure your application to serve static assets using 
>>> a ConfiguredAssetsBundle like this:
>>>
>>> public class MyApplication extends Application<MyAppConfiguration> {
>>>     // ...
>>>     @Override
>>>     public void initialize(final Bootstrap<MyAppConfiguration> bootstrap
>>> ) {
>>>         bootstrap.addBundle(new ViewBundle<>());
>>>         bootstrap.addBundle(new ConfiguredAssetsBundle("/assets/", 
>>> "/assets/", "index.html", "assets"));
>>>         bootstrap.addBundle(new ConfiguredAssetsBundle(
>>> "/META-INF/resources/webjars", "/webjars", "index.html", "webjars"));
>>>     }
>>>     // ...
>>> }
>>>
>>> You can configure multiple ConfiguredAssetsBundles, as seen above. The 
>>> second instance allows you to add WebJars <http://www.webjars.org> for 
>>> almost any JS/CSS library you might need.
>>>
>>> For a Metrics UI, I suggest you have a look at Grafana 
>>> <https://grafana.com> (for the UI) and Graphite 
>>> <https://github.com/graphite-project/graphite-web> (for the back-end 
>>> metrics service). To install Graphite, following the instructions here 
>>> <https://community.rackspace.com/products/f/25/t/6800>. Then install 
>>> Grafana, following the instructions here 
>>> <http://docs.grafana.org/installation/debian/>.
>>>
>>> I hope this helps.
>>>
>>> Regards,
>>> Doug
>>>
>>
>> Hi Douglas, thanks for your explanations!
>>
>> So the first line would be to tell Dropwizard that my resourcePath is 
>> /assets/, my uriPath is also /assets/, my indexFile is index.html and my 
>> assetsName is assets as seen here: 
>> https://github.com/dropwizard-bundles/dropwizard-configurable-assets-bundle/blob/master/src/main/java/io/dropwizard/bundles/assets/ConfiguredAssetsBundle.java#L173
>>
>> Is my assumption correct?
>>
>
> Yes, that's correct.
>  
>
>> About the second line, I would have to create directories 
>> /META-INF/resources/webjars inside /assets/ to have my webjars in 
>> /webjars/, again, am I following this through?
>>
>
> Actually, it's all taken care of for you, you don't need to do anything 
> other than create the ConfiguredAssetsBundle. With WebJars, the JS library 
> is packaged inside a jar file such that the static assets like .js and .css 
> files are stored inside the jar under the path 
> "/META-INF/resources/webjars". For example if you include JQuery in your 
> project:
>
>         <dependency>
>             <groupId>org.webjars</groupId>
>             <artifactId>jquery</artifactId>
>             <version>1.12.4</version>
>         </dependency>
>
> Then inside the jquery-1.12.4.jar the static assets are stored under the 
> path /META-INF/resources/webjars/jquery/1.12.4/... You can then load JQuery 
> in your web pages with:
>
>   <script src="/webjars/jquery/1.12.4/jquery.min.js"></script>
>
> The exact file names and paths inside the WebJars vary, so you'll want to 
> explore inside the jar files to see what exactly is available. Eclipse 
> allows you to easily look inside "Maven Dependencies" files; other IDEs 
> probably do too.
>  
>
>> In regards to Metrics UI, I have an idea for a Metrics UI that would be 
>> easily integrated to Dropwizard and maybe in the future be part of the 
>> bundle package, without depending on 3rd party software and its 
>> dependencies.
>> That's why I would like to know more about what is already there and 
>> where to see the possibility of extending and customizing it.
>>
>
> I think most people use Metrics by sending the metrics to an backend 
> server running Graphite or Ganglia or a commercial monitoring stack. 
> Graphite + Grafana is really good IMO. You can also access the raw metrics 
> as JSON if you access your app's adminConnector port with CURL or in a 
> browser. If you haven't looked at the adminConnector there are some basic 
> utilities available there:
>
> $ curl -G http://localhost:8986
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
>         "http://www.w3.org/TR/html4/loose.dtd";>
> <html>
> <head>
>   <title>Metrics</title>
> </head>
> <body>
>   <h1>Operational Menu</h1>
>   <ul>
>     <li><a href="/metrics?pretty=true">Metrics</a></li>
>     <li><a href="/ping">Ping</a></li>
>     <li><a href="/threads">Threads</a></li>
>     <li><a href="/healthcheck?pretty=true">Healthcheck</a></li>
>     <li><a href="/pprof">CPU Profile</a></li>
>     <li><a href="/pprof?state=blocked">CPU Contention</a></li>
>   </ul>
> </body>
> </html>
>
> It's pretty basic, though. It would certainly be nice if there was an 
> option, on development servers for example, to access the metrics in a 
> Grafana-like UI that was served directly by the Dropwizard-based app itself.
>
> Regards,
> Doug
>
>  Regards,
>
>>   Flavio Silveira
>>
>>
>>
Hi Douglas, thank you again for your quick reply!

I've done some testing and from what I can see I cannot use "/" as uriPath, 
am I correct? 

I've tried as below:

public void initialize(final Bootstrap<PhoenixConfiguration> bootstrap) {
    bootstrap.addBundle(new AssetsBundle("/assets", "/", "index.htm"));
}

and with that I get this error: Multiple servlets map to path /*: 
assets[mapped:JAVAX_API:null],io.dropwizard.jersey.setup.JerseyServletContainer-2c8662ac[mapped:EMBEDDED:null]

>From what I've searched it seems I need to move my application to another 
directory other than /, but I couldn't find the way of doing it in 1.1.2, 
on older versions it seems something 
like: environment.jersey().setUrlPattern("/api/*");

My idea is to serve just index.htm (or index.html) like 
mydomain.com/index.htm and use /js/ for JavaScript files, /css/ for CSS 
etc. Can this be done? What did I miss?

Regards,
  Flavio Silveira

-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to