Dropwizard jar 起動コマンドとその動作(出力結果)を忘れるので、備忘としてメモします。


前提

起動 jarプロジェクトルートに移動しておきます。
コマンドの${jarName}起動対象の jar 名に読み替えてください。


起動コマンド

以下、コマンドを記載します。

1. 引き数なしで実行

  • コマンド

    java -jar target/${jarName}.jar
    

  • 出力結果

    usage: java -jar ${jarName}.jar
           [-h] [-v] {server,check,xxxCommand} ...
    
    positional arguments:
      {server,check,xxxCommand}
                             available commands
    
    optional arguments:
      -h, --help             show this help message and exit
      -v, --version          show the application version and exit
    

  • 補足

    positional arguments:
      {server,check,xxxCommand}
                             available commands
    
    には、使用できるコマンドの一覧が出力されます。


2. -v付けて実行

  • コマンド

    java -jar target/${jarName}.jar -v
    

  • 出力結果

    0.0.1
    
    version番号が出力されます。


3. --version付けて実行

  • コマンド

    java -jar target/${jarName}.jar --version
    

  • 出力結果

    0.0.1
    
    これもversion番号が出力されます。


4. -h付けて実行

  • コマンド

    java -jar target/${jarName}.jar -h
    

  • 出力結果

    usage: java -jar ${jarName}.jar
           [-h] [-v] {server,check,xxxCommand} ...
    
    positional arguments:
      {server,check,xxxCommand}
                             available commands
    
    optional arguments:
      -h, --help             show this help message and exit
      -v, --version          show the application version and exit
    

  1. と同様の出力結果となります。

5. --help付けて実行

  • コマンド

    java -jar target/${jarName}.jar --help
    

  • 出力結果

    usage: java -jar ${jarName}.jar
           [-h] [-v] {server,check,xxxCommand} ...
    
    positional arguments:
      {server,check,xxxCommand}
                             available commands
    
    optional arguments:
      -h, --help             show this help message and exit
      -v, --version          show the application version and exit
    

これも1.と同じ出力になります。


6. check コマンド実行

  • コマンド

    java -jar target/${jarName}.jar check
    

  • 出力結果

    INFO  [2015-12-29 07:03:15,598] io.dropwizard.cli.CheckCommand: Configuration is OK
    

これはymlファイルを指定しないとあまり意味がないかもしれません。


7. check コマンド実行 (yml指定-問題なし)

  • コマンド

    java -jar target/${jarName}.jar check develop.yml
    

  • 出力結果

    INFO  [2015-12-29 07:03:15,598] io.dropwizard.cli.CheckCommand: Configuration is OK
    

  • ymlの内容

    # use the simple server factory if you only want to run on a single port
    server:
      applicationConnectors:
        - type: http
          port: 18080
      adminConnectors:
        - type: http
          port: 18081
    
    # Logging settings.
    logging:
    
      # The default level of all loggers. Can be OFF, ERROR, WARN, INFO, DEBUG, TRACE, or ALL.
      level: INFO
    
      # Logger-specific levels.
      loggers:
    
        # Sets the level for 'com.github.ko2ic' to DEBUG.
        com.github.ko2ic: DEBUG
    
      appenders:
        - type: console
          timeZone: JST
    


8. check コマンド実行 (yml指定-問題あり)

  • コマンド

    java -jar target/${jarName}.jar check develop.yml
    

  • 出力結果

    develop.yml has an error:
      * Unrecognized field at: loggingXXX
        Did you mean?:
          - logging
          - metrics
          - server
    

  • ymlの内容

    # use the simple server factory if you only want to run on a single port
    server:
      applicationConnectors:
        - type: http
          port: 18080
      adminConnectors:
        - type: http
          port: 18081
    
    # Logging settings.
    loggingXXX:
    
      # The default level of all loggers. Can be OFF, ERROR, WARN, INFO, DEBUG, TRACE, or ALL.
      level: INFO
    
      # Logger-specific levels.
      loggers:
    
        # Sets the level for 'com.github.ko2ic' to DEBUG.
        com.github.ko2ic: DEBUG
    
      appenders:
        - type: console
          timeZone: JST
    

設定ファイルに検証に使用できそうです。


9. check コマンド実行 (-v指定)

  • コマンド

    java -jar target/${jarName}.jar check -v
    

  • 出力結果

    unrecognized arguments: '-v'
    usage: java -jar ${jarName}.jar
           check [-h] [file]
    
    Parses and validates the configuration file
    
    positional arguments:
      file                   application configuration file
    
    optional arguments:
      -h, --help             show this help message and exit
    

-vオプションはないと言われます。
--versionなさそうで、
-h--helpオプションはありそうです。


10. check コマンド実行 (-h指定)

  • コマンド

    java -jar target/${jarName}.jar check -h
    

  • 出力結果

    usage: java -jar ${jarName}.jar
           check [-h] [file]
    
    Parses and validates the configuration file
    
    positional arguments:
      file                   application configuration file
    
    optional arguments:
      -h, --help             show this help message and exit
    

help出力されます。


11. check コマンド実行 (--help指定)

  • コマンド

    java -jar target/${jarName}.jar check --help
    

  • 出力結果

    usage: java -jar ${jarName}.jar
           check [-h] [file]
    
    Parses and validates the configuration file
    
    positional arguments:
      file                   application configuration file
    
    optional arguments:
      -h, --help             show this help message and exit
    

これもhelp出力されます。


12. server コマンド実行

  • コマンド

    java -jar target/${jarName}.jar server
    

  • 出力結果

    INFO  [2015-12-29 07:24:14,783] org.eclipse.jetty.util.log: Logging initialized @1714ms
    INFO  [2015-12-29 07:24:14,972] io.dropwizard.server.ServerFactory: Starting XXXApplication
    INFO  [2015-12-29 07:24:15,039] org.eclipse.jetty.setuid.SetUIDListener: Opened application@5b56b654{HTTP/1.1}{0.0.0.0:8080}
    INFO  [2015-12-29 07:24:15,040] org.eclipse.jetty.setuid.SetUIDListener: Opened admin@452c8a40{HTTP/1.1}{0.0.0.0:8081}
    INFO  [2015-12-29 07:24:15,043] org.eclipse.jetty.server.Server: jetty-9.2.z-SNAPSHOT
    INFO  [2015-12-29 07:24:15,433] io.dropwizard.jersey.DropwizardResourceConfig: The following paths were found for the configured resources:
    
        NONE
    
    INFO  [2015-12-29 07:24:15,436] org.eclipse.jetty.server.handler.ContextHandler: Started i.d.j.MutableServletContextHandler@73437222{/,null,AVAILABLE}
    INFO  [2015-12-29 07:24:15,441] io.dropwizard.setup.AdminEnvironment: tasks = 
    
        POST    /tasks/log-level (io.dropwizard.servlets.tasks.LogConfigurationTask)
        POST    /tasks/gc (io.dropwizard.servlets.tasks.GarbageCollectionTask)
    
    WARN  [2015-12-29 07:24:15,441] io.dropwizard.setup.AdminEnvironment: 
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    !    THIS APPLICATION HAS NO HEALTHCHECKS. THIS MEANS YOU WILL NEVER KNOW      !
    !     IF IT DIES IN PRODUCTION, WHICH MEANS YOU WILL NEVER KNOW IF YOU'RE      !
    !    LETTING YOUR USERS DOWN. YOU SHOULD ADD A HEALTHCHECK FOR EACH OF YOUR    !
    !         APPLICATION'S DEPENDENCIES WHICH FULLY (BUT LIGHTLY) TESTS IT.       !
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    INFO  [2015-12-29 07:24:15,446] org.eclipse.jetty.server.handler.ContextHandler: Started i.d.j.MutableServletContextHandler@763cf5b9{/,null,AVAILABLE}
    INFO  [2015-12-29 07:24:15,456] org.eclipse.jetty.server.ServerConnector: Started application@5b56b654{HTTP/1.1}{0.0.0.0:8080}
    INFO  [2015-12-29 07:24:15,456] org.eclipse.jetty.server.ServerConnector: Started admin@452c8a40{HTTP/1.1}{0.0.0.0:8081}
    INFO  [2015-12-29 07:24:15,456] org.eclipse.jetty.server.Server: Started @2389ms
    

デフォルト設定でアプリケーションが起動します。


13. server コマンド実行 (yml指定-問題なし)

  • コマンド

    java -jar target/${jarName}.jar server develop.yml
    

  • 出力結果

    INFO  [2015-12-29 16:28:34,173] org.eclipse.jetty.util.log: Logging initialized @1694ms
    INFO  [2015-12-29 16:28:34,356] io.dropwizard.server.ServerFactory: Starting XXXApplication
    INFO  [2015-12-29 16:28:34,424] org.eclipse.jetty.setuid.SetUIDListener: Opened application@79b663b3{HTTP/1.1}{0.0.0.0:18080}
    INFO  [2015-12-29 16:28:34,424] org.eclipse.jetty.setuid.SetUIDListener: Opened admin@1b812421{HTTP/1.1}{0.0.0.0:18081}
    INFO  [2015-12-29 16:28:34,427] org.eclipse.jetty.server.Server: jetty-9.2.z-SNAPSHOT
    INFO  [2015-12-29 16:28:34,813] io.dropwizard.jersey.DropwizardResourceConfig: The following paths were found for the configured resources:
    
        NONE
    
    INFO  [2015-12-29 16:28:34,816] org.eclipse.jetty.server.handler.ContextHandler: Started i.d.j.MutableServletContextHandler@2ab5afc7{/,null,AVAILABLE}
    INFO  [2015-12-29 16:28:34,821] io.dropwizard.setup.AdminEnvironment: tasks = 
    
        POST    /tasks/log-level (io.dropwizard.servlets.tasks.LogConfigurationTask)
        POST    /tasks/gc (io.dropwizard.servlets.tasks.GarbageCollectionTask)
    
    WARN  [2015-12-29 16:28:34,821] io.dropwizard.setup.AdminEnvironment: 
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    !    THIS APPLICATION HAS NO HEALTHCHECKS. THIS MEANS YOU WILL NEVER KNOW      !
    !     IF IT DIES IN PRODUCTION, WHICH MEANS YOU WILL NEVER KNOW IF YOU'RE      !
    !    LETTING YOUR USERS DOWN. YOU SHOULD ADD A HEALTHCHECK FOR EACH OF YOUR    !
    !         APPLICATION'S DEPENDENCIES WHICH FULLY (BUT LIGHTLY) TESTS IT.       !
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    INFO  [2015-12-29 16:28:34,825] org.eclipse.jetty.server.handler.ContextHandler: Started i.d.j.MutableServletContextHandler@6cd166b8{/,null,AVAILABLE}
    INFO  [2015-12-29 16:28:34,832] org.eclipse.jetty.server.ServerConnector: Started application@79b663b3{HTTP/1.1}{0.0.0.0:18080}
    INFO  [2015-12-29 16:28:34,833] org.eclipse.jetty.server.ServerConnector: Started admin@1b812421{HTTP/1.1}{0.0.0.0:18081}
    INFO  [2015-12-29 16:28:34,833] org.eclipse.jetty.server.Server: Started @2356ms
    

YMLファイルの設定でアプリケーションが起動します。


14. server コマンド実行 (-v指定)

  • コマンド

    java -jar target/${jarName}.jar server -v
    

  • 出力結果

    unrecognized arguments: '-v'
    usage: java -jar ${jarName}.jar
           server [-h] [file]
    
    Runs the Dropwizard application as an HTTP server
    
    positional arguments:
      file                   application configuration file
    
    optional arguments:
      -h, --help             show this help message and exit
    

-vオプションはないと言われます。
--versionなさそうで、
-h--helpオプションはありそうです。
*--version指定はコマンド単位にはないですね。


15. server コマンド実行 (-h指定)

  • コマンド

    java -jar target/${jarName}.jar server -h
    

  • 出力結果

    usage: java -jar ${jarName}.jar
           server [-h] [file]
    
    Runs the Dropwizard application as an HTTP server
    
    positional arguments:
      file                   application configuration file
    
    optional arguments:
      -h, --help             show this help message and exit
    

help出力されます。


16. server コマンド実行 (--help指定)

  • コマンド

    java -jar target/${jarName}.jar server --help
    

  • 出力結果

    usage: java -jar ${jarName}.jar
           server [-h] [file]
    
    Runs the Dropwizard application as an HTTP server
    
    positional arguments:
      file                   application configuration file
    
    optional arguments:
      -h, --help             show this help message and exit
    

これも help出力されます。

以上です。

コメント