| --- |
| active_crumb: Server <span class="amp">&</span> Probe |
| layout: documentation |
| id: server_and_probe |
| --- |
| |
| <!-- |
| Licensed to the Apache Software Foundation (ASF) under one or more |
| contributor license agreements. See the NOTICE file distributed with |
| this work for additional information regarding copyright ownership. |
| The ASF licenses this file to You under the Apache License, Version 2.0 |
| (the "License"); you may not use this file except in compliance with |
| the License. You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
| --> |
| |
| <div id="server-and-probes" class="col-md-8 second-column"> |
| <section> |
| <h2 class="section-title">Overview</h2> |
| <p> |
| As mentioned in <a href="/docs.html">overview</a> section the REST server and data probe are the two |
| runtime components that you need to run when using NLPCraft. |
| Data probes are used to deploy and host data model, while REST server (or a cluster of servers) is used |
| to accept client REST call and route them to the data models via data probes. |
| </p> |
| <div class="bq info"> |
| <b>REST Server vs. Data Probe</b> |
| <p> |
| It's important to remember why REST server is a separate component from a data probe. While a |
| typical deployment would have only one REST server (or a cluster of REST servers behind a single |
| load balancer), there are maybe multiple data probes hosting different data models deployed in |
| different physical locations, managed through different life cycles and requiring different |
| security and network configurations. |
| </p> |
| <p> |
| Moreover, REST server is a heavy and resource consuming component that is built around Apache |
| Ignite distributing in-memory computing capabilities - while the data probe is a lightweight |
| data model container. During the development and testing of data models, the developers need to |
| frequently redeploy data models by restarting the data probe. If the REST server and the data probe |
| would be one component - this process would be very inefficient. |
| </p> |
| </div> |
| <p> |
| Fro the rest of this section we assume that NLPCraft was <a href="/download.html">downloaded</a> and |
| <a href="/installation.html">installed</a> via ZIP archive. However, all instructions below are fully |
| applicable to any type of installation. |
| </p> |
| <p> |
| Once NLPCraft is downloaded as a ZIP archive and unzipped, the current directory will look like this: |
| </p> |
| <pre class="console"> |
| ├── LICENSE |
| ├── bin |
| ├── sql |
| ├── build |
| │ └── apache-nlpcraft-{{site.latest_version}} |
| │ ├── <b>nlpcraft.conf</b> |
| │ ├── ignite.xml |
| │ ├── log4j2.xml |
| │ └── <b>apache-nlpcraft-{{site.latest_version}}-all-deps.jar</b> |
| ├── javadoc |
| ├── openapi |
| └── src |
| </pre> |
| <p> |
| Regardless of how NLPCraft was installed it comes with a single executable JAR file that includes all |
| necessary dependencies: <code>build/apache-nlpcraft-{{site.latest_version}}/<b>apache-nlpcraft-{{site.latest_version}}-all-deps.jar</b></code>. |
| This JAR file includes binaries for data probe, data model APIs and the REST server. |
| </p> |
| </section> |
| <section id="server"> |
| <h2 class="section-title">REST Server</h2> |
| <p> |
| As mentioned above REST server (or a cluster of servers) is used to accept client REST calls and |
| route them to the data model via data probes. Note that both data probe and the REST server start the same way. |
| </p> |
| <p> |
| REST server can be stared in a <em>standard way</em> from either the command line or IDE such as Eclipse or IntelliJ IDEA: |
| </p> |
| <nav> |
| <div class="nav nav-tabs" role="tablist"> |
| <a class="nav-item nav-link active" data-toggle="tab" href="#nav-srv-jar" role="tab" aria-controls="nav-home" aria-selected="true">Executable JAR</a> |
| <a class="nav-item nav-link" data-toggle="tab" href="#nav-srv-cmd" role="tab" aria-controls="nav-home" aria-selected="true">Command Line</a> |
| <a class="nav-item nav-link" data-toggle="tab" href="#nav-srv-ide" role="tab" aria-controls="nav-home" aria-selected="true">IDE</a> |
| <a class="nav-item nav-link" data-toggle="tab" href="#nav-srv-docker" role="tab" aria-controls="nav-home" aria-selected="true"><i class="fab fa-docker"></i> Docker</a> |
| </div> |
| </nav> |
| <div class="tab-content"> |
| <div class="tab-pane fade show active" id="nav-srv-jar" role="tabpanel"> |
| <pre class="brush: plain"> |
| $ cd build |
| $ java -Xms1024m -jar apache-nlpcraft-{{site.latest_version}}-all-deps.jar -server |
| </pre> |
| </div> |
| <div class="tab-pane fade show" id="nav-srv-cmd" role="tabpanel"> |
| <pre class="brush: plain"> |
| $ cd build |
| $ java -Xms1024m -cp apache-nlpcraft-{{site.latest_version}}-all-deps.jar org.apache.nlpcraft.NCStart -server |
| </pre> |
| </div> |
| <div class="tab-pane fade show" id="nav-srv-ide" role="tabpanel"> |
| <p style="padding-top: 10px"> |
| Configure run configuration with the main class <code>org.apache.nlpcraft.NCStart</code>. |
| Note that <code>org.apache.nlpcraft.NCStart</code> class starts both the REST server and the data probe and is the |
| class that is configured as <code>Main-Class</code> in <code>apache-nlpcraft-{{site.latest_version}}-all-deps.jar</code> |
| JAR file manifest. |
| </p> |
| </div> |
| <div class="tab-pane fade show" id="nav-srv-docker" role="tabpanel"> |
| <pre class="brush: plain"> |
| $ docker run -m 8G -p 8081:8081 -p 8201:8201 -p 8202:8202 nlpcraftserver/server:{{site.latest_version}} |
| </pre> |
| <p> |
| By default, the Docker image runs with a default configuration. |
| See <a href="#config">configuration</a> section on how to provide custom configuration via environment variables for the REST |
| server running inside of Docker container. |
| </p> |
| </div> |
| </div> |
| Parameters: |
| <dl> |
| <dt> |
| <code>-server</code> |
| </dt> |
| <dd> |
| <em>Mandatory</em> parameter to indicate that you are starting the REST server. |
| </dd> |
| <dt><code>-config=path</code></dt> |
| <dd> |
| <em>Optional</em> parameter to provide configuration file path. |
| Server will automatically look for <code>nlpcraft.conf</code> configuration file in the same directory |
| as <code>apache-nlpcraft-{{site.latest_version}}-all-deps.jar</code> file. If the configuration |
| file has different name or in different location use <code>-config=path</code> parameter |
| where <code>path</code> is an absolute path to the configuration file. Note that the server and the data |
| probe can use the same file for their configuration (just like the |
| default <code>nlpcraft.conf</code> contains configuration for both the server and the data probe). |
| </dd> |
| <dt><code>-igniteConfig=path</code></dt> |
| <dd> |
| <em>Optional</em> parameter to provide <a target=_ href="https://ignite.apache.org/">Apache Ignite</a> configuration file path. |
| Note that Apache Ignite is used as a cluster computing plane and a default distributed storage. |
| Server will automatically look for <code>ignite.xml</code> |
| configuration file in the same directory as <code>apache-nlpcraft-{{site.latest_version}}-all-deps.jar</code> file. |
| If the configuration file has different name or in different location use <code>-igniteConfig=path</code> parameter |
| where <code>path</code> is an absolute path to the Ignite configuration file. |
| </dd> |
| </dl> |
| <div class="bq warn"> |
| <b>Java Memory</b> |
| <p> |
| Make sure to allocate enough memory for server JVM using <code>-Xms</code> JVM option, i.e. <code>-Xms1024m</code>. |
| Many 3rd party NLP engines like Stanford CoreNLP are very memory intensive and may require several GBs |
| of JVM heap allocated depending on the models used. Note that when server JVM has insufficient heap |
| memory the Apache Ignite may throw the following warning logs: |
| </p> |
| <pre class="brush: text, highlight: 2"> |
| Jul-22 13:27:56 [INFO ] ... |
| Jul-22 13:28:08 [WARN ] Possible too long JVM pause: 11364 milliseconds. |
| Jul-22 13:28:11 [INFO ] ... |
| </pre> |
| <p> |
| The abnormally long GC pauses (over 5s) can be caused by the excessive memory swapping performed by OS due to |
| insufficient JVM heap memory. |
| </p> |
| </div> |
| <p> |
| When the REST server successfully started you should see the log output similar to this: |
| </p> |
| <pre class="brush: plain, highlight: 19"> |
| _ ____ ______ ______ |
| / | / / /___ / ____/________ _/ __/ /_ |
| / |/ / / __ \/ / / ___/ __ `/ /_/ __/ |
| / /| / / /_/ / /___/ / / /_/ / __/ /_ |
| /_/ |_/_/ .___/\____/_/ \__,_/_/ \__/ |
| /_/ |
| |
| Server |
| Version: {{site.latest_version}} |
| Copyright (C) 2020 Apache Software Foundation. |
| |
| ... |
| |
| +-------------------------+ |
| | Server started [19.35s] | |
| +-------------------------+ |
| |
| |
| Mar-11 23:21:04 [INFO ] REST server is listening on 'localhost:8081'. |
| </pre> |
| </section> |
| <section id="probe"> |
| <h2 class="section-title">Data Probe</h2> |
| <p> |
| Just like the REST server the data probe can be started in a <em>standard way</em> from either the |
| command line or IDE such as Eclipse or IntelliJ IDEA: |
| </p> |
| <nav> |
| <div class="nav nav-tabs" role="tablist"> |
| <a class="nav-item nav-link active" data-toggle="tab" href="#nav-probe-cmd" role="tab" aria-controls="nav-home" aria-selected="true">Command Line</a> |
| <a class="nav-item nav-link" data-toggle="tab" href="#nav-probe-jar" role="tab" aria-controls="nav-home" aria-selected="true">Executable JAR</a> |
| <a class="nav-item nav-link" data-toggle="tab" href="#nav-probe-ide" role="tab" aria-controls="nav-home" aria-selected="true">IDE</a> |
| </div> |
| </nav> |
| <div class="tab-content"> |
| <div class="tab-pane fade show" id="nav-probe-jar" role="tabpanel"> |
| <pre class="brush: plain"> |
| $ cd build |
| $ java -Xms1024m -jar apache-nlpcraft-{{site.latest_version}}-all-deps.jar -probe |
| </pre> |
| <div class="bq warn"> |
| <p> |
| <b>NOTE:</b> when using executable JAR to start the data probe you cannot add your |
| own model classes to the classpath. You should either package your classes into JAR |
| file and configure probe accordingly - or use <code>-cp</code> option in |
| command line. |
| </p> |
| </div> |
| </div> |
| <div class="tab-pane fade show active" id="nav-probe-cmd" role="tabpanel"> |
| <pre class="brush: plain"> |
| $ cd build |
| $ java -Xms1024m -cp apache-nlpcraft-{{site.latest_version}}-all-deps.jar:/my/project/classes org.apache.nlpcraft.NCStart -probe -config=/my/project/probe.conf |
| </pre> |
| <p> |
| Directory <code>/my/project/classes</code> should contain all compiled classes for your models. |
| Make sure to replace <code>/my/project/classes</code> and <code>/my/project/probe.conf</code> with |
| the actual paths. |
| </p> |
| </div> |
| <div class="tab-pane fade show" id="nav-probe-ide" role="tabpanel"> |
| <p style="padding-top: 10px"> |
| Configure run configuration with the main class <code>org.apache.nlpcraft.NCStart</code>. |
| </p> |
| <div class="bq info"> |
| <b>Class <code>org.apache.nlpcraft.NCStart</code></b> |
| <p> |
| Note that <code>org.apache.nlpcraft.NCStart</code> class starts both the REST server and the data probe and is the |
| class that is configured as <code>Main-Class</code> in <code>apache-nlpcraft-{{site.latest_version}}-all-deps.jar</code> |
| JAR file manifest. |
| </p> |
| </div> |
| </div> |
| </div> |
| Parameters: |
| <dl> |
| <dt> |
| <code>-probe</code> |
| </dt> |
| <dd> |
| <em>Mandatory</em> parameter to indicate that you are starting a data probe. |
| </dd> |
| <dt><code>-config=path</code></dt> |
| <dd> |
| <p> |
| <em>Optional</em> parameter to provide probe configuration file path. |
| Data probe will automatically look for <code>nlpcraft.conf</code> configuration file in the same directory |
| as <code>apache-nlpcraft-{{site.latest_version}}-all-deps.jar</code> file. If the configuration |
| file has different name or in different location use <code>-config=path</code> parameter |
| where <code>path</code> is an absolute path to the data probe configuration file. Note that the server and the data |
| probe can use the same file for their configuration (just like the |
| default <code>nlpcraft.conf</code> contains configuration for both the server and the data probe). |
| </p> |
| </dd> |
| </dl> |
| <div class="bq info"> |
| <b>Adding Your Classes</b> |
| <p> |
| Note that when you are using a <em>command line</em> to start the probe you can also add your own classes that implement |
| your models. To do that you need to use <code>-cp</code> option instead of <code>-jar</code> and |
| construct your JVM classpath to include both the <code>apache-nlpcraft-{{site.latest_version}}-all-deps.jar</code> |
| as well as directory where your compiled Java code is located: |
| </p> |
| <pre class="brush: plain, highlight: 2"> |
| $ cd build |
| $ java -cp apache-nlpcraft-{{site.latest_version}}-all-deps.jar:/my/project/classes org.apache.nlpcraft.NCStart -probe -config /my/project/probe.conf |
| </pre> |
| Make sure to replace <code>/my/project/classes</code> with your own directory where your compiled model classes |
| are located. Note that you need to specify class <code>org.apache.nlpcraft.NCStart</code> explicitly in this case. |
| </div> |
| <p> |
| When the data probe started you should see the log output similar to this: |
| </p> |
| <pre class="brush: plain"> |
| _ ____ ______ ______ |
| / | / / /___ / ____/________ _/ __/ /_ |
| / |/ / / __ \/ / / ___/ __ `/ /_/ __/ |
| / /| / / /_/ / /___/ / / /_/ / __/ /_ |
| /_/ |_/_/ .___/\____/_/ \__,_/_/ \__/ |
| /_/ |
| |
| Data Probe |
| Version: {{site.latest_version}} |
| Copyright (C) 2020 Apache Software Foundation. |
| |
| Mar-11 23:25:52 [INFO ] Probe Configuration: |
| +--------------------------------------------------------------------+ |
| | Probe ID | all.examples | |
| | Probe Token | 3141592653589793 | |
| | API Version | {{site.latest_version}}, 2019-03-01 | |
| | Down-Link | localhost:8202 | |
| | Up-Link | localhost:8201 | |
| +-----------------+--------------------------------------------------+ |
| | Models | org.apache.nlpcraft.examples.alarm.AlarmModel | |
| | | org.apache.nlpcraft.examples.echo.EchoModel | |
| | | org.apache.nlpcraft.examples.time.TimeModel | |
| | | org.apache.nlpcraft.examples.weather.WeatherModel| |
| +-----------------+--------------------------------------------------+ |
| | Lifecycle | | |
| | JARs Folder | | |
| +--------------------------------------------------------------------+ |
| |
| ... |
| |
| Mar-11 23:25:56 [INFO ] Models deployed: 5 |
| |
| +================================================================================+ |
| | Model ID | Name | Ver. | Elements | Synonyms | |
| +================================================================================+ |
| | nlpcraft.alarm.ex | Alarm Example Model | 1.0 | 1 | 419 | |
| | nlpcraft.weather.ex | Weather Example Model | 1.0 | 3 | 9045 | |
| | nlpcraft.time.ex | Time Example Model | 1.0 | 1 | 432 | |
| | nlpcraft.echo.ex | Echo Example Model | 1.0 | 0 | 0 | |
| +--------------------------------------------------------------------------------+ |
| |
| ... |
| |
| +--------------------------+ |
| | Probe started [5.12 sec] | |
| +--------------------------+ |
| |
| ... |
| |
| Mar-11 23:25:58 [INFO ] Server connection established. |
| </pre> |
| </section> |
| <section id="config"> |
| <h2 class="section-title">Configuration</h2> |
| <p> |
| Both REST server and the data probe use <a target=_ href="https://github.com/lightbend/config/">Typesafe Config</a> for their configuration: |
| </p> |
| <ul> |
| <li>Both the server and the data probe come with default configuration available in <code>build/<b>nlpcraft.conf</b></code> file.</li> |
| <li>Custom configuration or default overrides can be placed into a file or provided via environment variables.</li> |
| <li>Configuration files use <a target=_ href="https://github.com/lightbend/config/blob/master/HOCON.md">HOCON</a> file format.</li> |
| <li> |
| Server and probe configuration can be placed in the same file (as it is shipped by default in <code>build/nlpcraft.conf</code> file) |
| or kept in separate files. When kept in separate files each file would have either <code>nlpcraft.server</code> |
| or <code>nlpcraft.probe</code> sub-section. |
| </li> |
| </ul> |
| |
| <p> |
| By default, when REST server or data probe start they look for <code>nlpcraft.conf</code> configuration file in the same directory |
| as <code>apache-nlpcraft-{{site.latest_version}}-all-deps.jar</code> file and the on their classpath. You can change this behavior with |
| <code>-config=path</code> parameter. |
| </p> |
| <p> |
| Default configuration is available in <code>build/<b>nlpcraft.conf</b></code> file and it is extensively documented. It has subsections |
| for the server and probe configuration. When server and the probe use different files these whole sections should be |
| placed into an individual files: |
| </p> |
| <p> |
| Server configuration file (e.g. <code>server_nlpcraft.conf</code>): |
| </p> |
| <pre class="brush: js"> |
| nlpcraft { |
| server { |
| ... |
| } |
| } |
| </pre> |
| <p> |
| Probe configuration file (e.g. <code>probe_nlpcraft.conf</code>): |
| </p> |
| <pre class="brush: js"> |
| nlpcraft { |
| probe { |
| ... |
| } |
| } |
| </pre> |
| </section> |
| <section id="override"> |
| <h2 class="section-title">Custom Configuration</h2> |
| <p> |
| While you can change configuration file or files for your own needs (and use <code>-config=...</code> |
| parameter described above to provide path to that file) it is often more convenient to use the default configuration file and just |
| change one or two properties in it. You can accomplish this by using standard |
| <a target=_ href="https://github.com/lightbend/config#optional-system-or-env-variable-overrides">HOCON overriding</a> |
| via environment variables: |
| </p> |
| <ol> |
| <li> |
| Set probe or server JVM system property <code>-Dconfig.override_with_env_vars=true</code> which will instruct |
| configuration framework to look for external overrides. |
| </li> |
| <li>For each configuration property <code>x.y.z</code> set the overriding environment variable <code>CONFIG_FORCE_x_y_z=some_value</code></li> |
| <li>See more details on <a target=_ href="https://github.com/lightbend/config#optional-system-or-env-variable-overrides">HOCON documentation</a>.</li> |
| </ol> |
| <p> |
| Consider the following snippet of NLPCraft configuration: |
| </p> |
| <pre class="brush: js"> |
| nlpcraft { |
| probe { |
| models = "com.nlp.MyModel" |
| } |
| |
| server { |
| lifecycle = "org.apache.nlpcraft.server.lifecycle.opencensus.NCJaegerExporter" |
| |
| rest { |
| host = "0.0.0.0" |
| port = 8081 |
| apiImpl = "org.apache.nlpcraft.server.rest.NCBasicRestApi" |
| } |
| } |
| } |
| </pre> |
| <p> |
| You can override these properties with the following environment variables: |
| </p> |
| <p> |
| <code>CONFIG_FORCE_<b>nlpcraft_server_rest_host</b>=1.2.3.4</code><br> |
| <code>CONFIG_FORCE_<b>nlpcraft_server_lifecycle</b>="org.nlp.Lifecycle1, org.nlp.Lifecycle1"</code><br> |
| <code>CONFIG_FORCE_<b>nlpcraft_probe_models</b>="com.nlp.MyModel, com.nlp.AnotherModel"</code> |
| </p> |
| <div class="bq info"> |
| <b>Examples</b> |
| <p> |
| Note that all examples that come with NLPCraft have instructions that use environment variable overriding |
| for running their data probes. They use default <code>nlpcraft.conf</code> file and just override |
| one <code>nlpcraft.probe.models</code> property (see above) to specify what model the data probe |
| needs to deploy. |
| </p> |
| </div> |
| </section> |
| <section id="ansi"> |
| <h2 class="section-title">ANSI Colors</h2> |
| <p> |
| Both NLPCraft server and probe use ANSI coloring via |
| <a target=_ href="https://en.wikipedia.org/wiki/ANSI_escape_code">ANSI escape sequences</a> for their log |
| output by default. ANSI coloring provides easer console log comprehension and modern estethics. |
| </p> |
| <figure> |
| <img class="img-fluid-no-border" src="/images/ansi_colors.png" alt=""> |
| <figcaption><b>Fig 1.</b> ANSI Colors</figcaption> |
| </figure> |
| <p> |
| However, there are |
| cases when either specific console does not support ANSI escape sequences, or specific color schema |
| isn't suitable or log being redirected to a file or piped to downstream system. In these cases you need to |
| disable ANSI coloring to avoid polluting log with unprocessed ANSI escape codes. |
| </p> |
| <p> |
| You can disable ANSI coloring in either server, probe or both by supplying the following system |
| property to JVM process: <code>-D<b>NLPCRAFT_ANSI_COLOR_DISABLED</b>=true</code> |
| </p> |
| </section> |
| <section id="testing"> |
| <h2 class="section-title">Testing</h2> |
| <p> |
| It is a good practice to run units tests during routine builds using Maven (or others CI toolchains). To |
| test data models you need to have a running server and then start one or more data probes with |
| models you want to test. While doing this from IDE can be trivial enough, doing this from Maven |
| can be tricky. |
| </p> |
| <p> |
| The challenge is that from the Maven build you need to start the server, wait til its fully started and |
| initialized, and only then start issuing REST calls, start data probes or run tests that use <a href="/tools/embedded_probe.html">embedded probes</a>. |
| When done manually (e.g. from IDE) you can visually observe when the server finished its startup and then manually |
| launch the tests. In Maven, however, you need to use a special plugin to accomplish the same in |
| automated fashion. |
| </p> |
| <div class="bq info"> |
| <b>Probe Waits For Server</b> |
| <p> |
| Technically, when a data probe starts up it will initialize, load the models, and will automatically wait for the server to get online |
| if it isn't yet (as well as periodically check for it). Once server is online the data probe will automatically connect to it. However, |
| if the unit tests don't use data probe and just issue REST calls then these tests have to somehow wait for the |
| server to get online. |
| </p> |
| <p> |
| To overcome this challenge you can use |
| <a target="github" href="https://github.com/bazaarvoice/maven-process-plugin"><code>process-exec-maven-plugin</code></a> |
| Maven plugin. |
| </p> |
| </div> |
| <p> |
| To get around this problem NLPCraft uses <a target="github" href="https://github.com/bazaarvoice/maven-process-plugin"><code>process-exec-maven-plugin</code></a> |
| Maven plugin in its own build. This plugin allows to start the external process and use configured URL |
| endpoint to check whether or not the external process has fully started. This works perfect with NLPCraft server |
| <a href="using-rest.html#misc">health check REST call</a>. The plugin can be configured in the following way for your own project |
| (taken directly from NLPCraft <a target="github" href="https://github.com/apache/incubator-nlpcraft/blob/master/nlpcraft/pom.xml"><code>pom.xml</code></a>): |
| </p> |
| <pre class="brush: xml, highlight: [14, 16, 28]"> |
| <plugin> |
| <groupId>com.bazaarvoice.maven.plugins</groupId> |
| <artifactId>process-exec-maven-plugin</artifactId> |
| <version>0.9</version> |
| <executions> |
| <execution> |
| <id>pre-integration-test</id> |
| <phase>pre-integration-test</phase> |
| <goals> |
| <goal>start</goal> |
| </goals> |
| <configuration> |
| <name>server</name> |
| <healthcheckUrl>http://localhost:8081/api/v1/health</healthcheckUrl> |
| <waitAfterLaunch>180</waitAfterLaunch> |
| <processLogFile>${project.build.directory}/server.log</processLogFile> |
| <arguments> |
| <argument>java</argument> |
| <argument>-Xmx4G</argument> |
| <argument>-Xms4G</argument> |
| <argument>--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED</argument> |
| <argument>--add-exports=java.base/sun.nio.ch=ALL-UNNAMED</argument> |
| <argument>--add-exports=java.management/com.sun.jmx.mbeanserver=ALL-UNNAMED</argument> |
| <argument>--add-exports=jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED</argument> |
| <argument>--add-exports=java.base/sun.reflect.generics.reflectiveObjects=ALL-UNNAMED</argument> |
| <argument>--add-opens=jdk.management/com.sun.management.internal=ALL-UNNAMED</argument> |
| <argument>--illegal-access=permit</argument> |
| <argument>-DNLPCRAFT_ANSI_COLOR_DISABLED=true</argument> |
| <argument>-Djdk.tls.client.protocols=TLSv1.2</argument> |
| <argument>-jar</argument> |
| <argument>${project.build.directory}/${nlpcraft.all.deps.jar}</argument> |
| <argument>-server</argument> |
| </arguments> |
| </configuration> |
| </execution> |
| <execution> |
| <id>stop-all</id> |
| <phase>post-integration-test</phase> |
| <goals> |
| <goal>stop-all</goal> |
| </goals> |
| </execution> |
| </executions> |
| </plugin> |
| </pre> |
| <p> |
| <b>NOTES</b>: |
| </p> |
| <ul> |
| <li> |
| On line 14 we specify the URL endpoint to check whether or not our server is online. We use |
| <code>/health</code> localhost REST call for that. |
| </li> |
| <li> |
| On line 16 we redirect the output from server to a dedicated file to <b>avoid interleaving</b> log |
| from server and log from data probe in the same console (where we are running the Maven build from). |
| Such interleaving will make the combined log unreadable and can cause output problem for the console |
| due to mixed up ANSI escape sequences from server and data probe. |
| </li> |
| <li> |
| Since the server log is piped out to a separate file we disable ANSI coloring for the server |
| on the line 28. |
| </li> |
| </ul> |
| <div class="bq info"> |
| <b>Avoid Interleaving Logs</b> |
| <p> |
| When running both server and the data probe(s) from the Maven build it is important to avoid interleaving |
| logs from the server and the probe. Such interleaving will make the combined log in Maven unreadable and |
| can cause console malfunction due to mixed up ANSI escape codes. It is idiomatic in such cases to: |
| </p> |
| <ul> |
| <li> |
| Disable ANSI coloring for the server via <code>-D<b>NLPCRAFT_ANSI_COLOR_DISABLED</b>=true</code> |
| </li> |
| <li> |
| Pipe out the server log into a dedicated file using Maven plugins like |
| <a target="github" href="https://github.com/bazaarvoice/maven-process-plugin"><code>process-exec-maven-plugin</code></a>. |
| </li> |
| </ul> |
| </div> |
| </section> |
| </div> |
| <div class="col-md-2 third-column"> |
| <ul class="side-nav"> |
| <li class="side-nav-title">On This Page</li> |
| <li><a href="#server">REST Server</a></li> |
| <li><a href="#probe">Data Probe</a></li> |
| <li><a href="#config">Configuration</a></li> |
| <li><a href="#override">Custom Configuration</a></li> |
| <li><a href="#ansi">ANSI Colors</a></li> |
| <li><a href="#testing">Testing</a></li> |
| {% include quick-links.html %} |
| </ul> |
| </div> |