ANierbeck / Karaf-Vertx

Showcase to demonstrate Vertx in OSGi and especially in Karaf
Apache License 2.0
20 stars 5 forks source link

Add a metrics Dashboard to showcase #19

Closed ANierbeck closed 7 years ago

anhldbk commented 7 years ago

@ANierbeck How to access the Dashboard GUI?

ANierbeck commented 7 years ago

@anhldbk ... could be found in the sources ;) https://github.com/ANierbeck/Karaf-Vertx/commit/09ecf5e15c9e5cb4a4908c82cf18e795e44a32de#diff-bccf593ea77a28e62815e7e3a9c351acR105 it's /metrics

anhldbk commented 7 years ago

@ANierbeck When I access http://localhost:8080/metrics/index.html, I've got an exception of:

Caused by: java.nio.file.FileSystemException: .vertx/file-cache-b968ce38-5354-4cf7-aa16-08bb5b982ab4/10.0/webroot/index.html: Not a directory
    at sun.nio.fs.UnixException.translateToIOException(UnixException.java:91) ~[?:?]
    at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102) ~[?:?]
    at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107) ~[?:?]
    at sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:214) ~[?:?]
    at java.nio.file.spi.FileSystemProvider.newOutputStream(FileSystemProvider.java:434) ~[?:?]
    at java.nio.file.Files.newOutputStream(Files.java:216) ~[?:?]
    at java.nio.file.Files.copy(Files.java:3016) ~[?:?]
    at io.vertx.core.impl.FileResolver.unpackFromBundleURL(FileResolver.java:273) ~[?:?]
    ... 48 more

The problem is webroot is not properly extracted to directory .vertx/file-cache-b968ce38-5354-4cf7-aa16-08bb5b982ab4/10.0. I solved by manually copying webroot to the directory.

Would you please tell me what wrong is?

anhldbk commented 7 years ago

In file MetricsDashboard.java, currently we have:

// line 90
router.route("/*").handler(StaticHandler.create("webroot", this.getClass().getClassLoader()));

I modified to:

router.route("/*").handler(StaticHandler.create().setWebRoot("we‌​broot"));

@ANierbeck Should I make a PR against this issue?

ANierbeck commented 7 years ago

How do you use it? Inside an OSGi environment, in that case you should keep the classloader part :)

anhldbk commented 7 years ago

@ANierbeck I just entered bin/karaf and navigated to /metrics

Vertx-Microservices-Karaf/target/assembly on 🐳 v17.06.1-ce 
➜ bin/karaf
        __ __                  ____      
       / //_/____ __________ _/ __/      
      / ,<  / __ `/ ___/ __ `/ /_        
     / /| |/ /_/ / /  / /_/ / __/        
    /_/ |_|\__,_/_/   \__,_/_/         

  Apache Karaf (4.1.1)

Hit '<tab>' for a list of available commands
and '[cmd] --help' for help on a specific command.
Hit '<ctrl-d>' or type 'system:shutdown' or 'logout' to shutdown Karaf.

Configuration changed
karaf@root()>