Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#2115 Unable to stop hop-server from command-line #2229

Merged
merged 2 commits into from
Feb 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions assemblies/static/src/main/resources/hop-server.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<name>server-8181</name>
<hostname>localhost</hostname>
<port>8181</port>
<shutdownPort>8182</shutdownPort>
</hop-server>

<!-- Join the web server thread and wait until it's finished.
Expand Down
5 changes: 3 additions & 2 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ ENV HOP_SERVER_PASSWORD=cluster
# The server hostname
ENV HOP_SERVER_HOSTNAME=0.0.0.0
ENV HOP_SERVER_PORT=8080
ENV HOP_SERVER_SHUTDOWNPORT=8079
# Optional metadata folder to be included in the hop server XML
ENV HOP_SERVER_METADATA_FOLDER=
# Optional server SSL configuration variables
Expand Down Expand Up @@ -114,8 +115,8 @@ COPY --chown=hop:hop ./assemblies/client/target/hop/ ${DEPLOYMENT_PATH}/hop
COPY --chown=hop:hop ./docker/resources/run.sh ${DEPLOYMENT_PATH}/run.sh
COPY --chown=hop:hop ./docker/resources/load-and-execute.sh ${DEPLOYMENT_PATH}/load-and-execute.sh

# expose 8080 for Hop Server
EXPOSE 8080
# expose 8080/8079 for Hop Server
EXPOSE 8080 8079

# make volume available so that hop pipeline and workflow files can be provided easily
VOLUME ["/files"]
Expand Down
1 change: 1 addition & 0 deletions docker/resources/load-and-execute.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ write_server_config() {
echo " <name>Hop Server</name>" >>${HOP_SERVER_XML}
echo " <hostname>${HOP_SERVER_HOSTNAME}</hostname>" >>${HOP_SERVER_XML}
echo " <port>${HOP_SERVER_PORT}</port>" >>${HOP_SERVER_XML}
echo " <shutdownPort>${HOP_SERVER_SHUTDOWNPORT}</shutdownPort>" >>${HOP_SERVER_XML}
echo " <username>${HOP_SERVER_USER}</username>" >>${HOP_SERVER_XML}
echo " <password>${HOP_SERVER_PASS}</password>" >>${HOP_SERVER_XML}

Expand Down
6 changes: 6 additions & 0 deletions docs/hop-tech-manual/modules/ROOT/pages/docker-container.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ Below are the variables you can use for a **long-lived** container, running Hop
| `8080`
| The port the server will listen to.

|```HOP_SERVER_SHUTDOWNPORT```
| `8079`
| The port the server shutdown listener will listen to.

|```HOP_SERVER_USER```
|`cluster`
| The username to log into the Hop server.
Expand Down Expand Up @@ -259,8 +263,10 @@ docker run -it --rm \
--env HOP_SERVER_USER=admin \
--env HOP_SERVER_PASS=admin \
--env HOP_SERVER_PORT=8181 \
--env HOP_SERVER_PORT=8180 \
--env HOP_SERVER_HOSTNAME=0.0.0.0 \
-p 8181:8181 \
-p 8180:8180 \
--name my-hop-server-container \
apache/hop:<tag>
----
Expand Down
25 changes: 24 additions & 1 deletion docs/hop-user-manual/modules/ROOT/pages/hop-server/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ Example: `hop-server.sh -e aura-gcp gs://apachehop/hop-server-config.xml`
Example: `hop-server.bat 127.0.0.1 8080 --kill --userName cluster --password cluster`

[source,shell]
hop-server <Interface address> <Port> [-h] [-p <arg>] [-s] [-u <arg>]
hop-server <Interface address> <Port> [ShutdownPort] [-h] [-p <arg>] [-s] [-u <arg>]

Example startup commands are:

Expand Down Expand Up @@ -203,6 +203,7 @@ The syntax of this configuration file is fairly simple:
<name>server-8181</name>
<hostname>localhost</hostname>
<port>8181</port>
<shutdownPort>8182</shutdownPort>
</hop-server>

<!-- Join the web server thread and wait until it's finished.
Expand Down Expand Up @@ -384,7 +385,9 @@ Here is an example of how you would start a "long-lived" docker container:
----
docker run \
-p 8080:8080 \
-p 8079:8079 \
-e HOP_SERVER_PORT=8080 \
-e HOP_SERVER_SHUTDOWNPORT=8079 \
-e HOP_SERVER_USER=username \
-e HOP_SERVER_USER=password \
apache/hop
Expand All @@ -395,6 +398,7 @@ docker run \
In a testing setup where Hop Server was started from a terminal, the process can be terminated through `CTRL-C`.

In headless environments, the same hop-server command used to start the server can be used to stop it:
A default listener on shutdown port is configured on port number `8079` when not specifying this in the command it will be used.

[tabs]
====
Expand All @@ -413,6 +417,25 @@ hop-server.sh 127.0.0.1 8080 -k -u cluster -p cluster
--
====

You can also trigger the command on a specific shutdown port

[tabs]
====
Windows::
+
--
[source,shell]
hop-server.bat 127.0.0.1 8080 8079 -k -u cluster -p cluster
--

Linux, macOS::
+
--
[source,shell]
hop-server.sh 127.0.0.1 8080 8079 -k -u cluster -p cluster
--
====

== Verify startup

Starting a Hop Server on the local machine e.g. on port 8081 will only take 1 or 2 seconds.
Expand Down
47 changes: 43 additions & 4 deletions engine/src/main/java/org/apache/hop/server/HopServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ public static int getBackoffIncrements() {

@HopMetadataProperty private String port;

@HopMetadataProperty private String shutdownPort;

@HopMetadataProperty private String webAppName;

@HopMetadataProperty private String username;
Expand Down Expand Up @@ -173,26 +175,44 @@ public HopServer() {
this.changedDate = new Date();
}

public HopServer(String name, String hostname, String port, String username, String password) {
this(name, hostname, port, username, password, null, null, null, false);
public HopServer(
String name,
String hostname,
String port,
String shutdownPort,
String username,
String password) {
this(name, hostname, port, shutdownPort, username, password, null, null, null, false);
}

public HopServer(
String name,
String hostname,
String port,
String shutdownPort,
String username,
String password,
String proxyHostname,
String proxyPort,
String nonProxyHosts) {
this(name, hostname, port, username, password, proxyHostname, proxyPort, nonProxyHosts, false);
this(
name,
hostname,
port,
shutdownPort,
username,
password,
proxyHostname,
proxyPort,
nonProxyHosts,
false);
}

public HopServer(
String name,
String hostname,
String port,
String shutdownPort,
String username,
String password,
String proxyHostname,
Expand All @@ -203,6 +223,7 @@ public HopServer(
this.name = name;
this.hostname = hostname;
this.port = port;
this.shutdownPort = shutdownPort;
this.username = username;
this.password = password;

Expand All @@ -218,6 +239,7 @@ public HopServer(Node node) {
this.name = XmlHandler.getTagValue(node, "name");
this.hostname = XmlHandler.getTagValue(node, "hostname");
this.port = XmlHandler.getTagValue(node, "port");
this.shutdownPort = XmlHandler.getTagValue(node, "shutdownPort");
this.webAppName = XmlHandler.getTagValue(node, "webAppName");
this.username = XmlHandler.getTagValue(node, "username");
this.password =
Expand Down Expand Up @@ -251,6 +273,7 @@ public String getXml(IVariables variables) {
xml.append(" ").append(XmlHandler.addTagValue("name", name));
xml.append(" ").append(XmlHandler.addTagValue("hostname", hostname));
xml.append(" ").append(XmlHandler.addTagValue("port", port));
xml.append(" ").append(XmlHandler.addTagValue("shutdownPort", shutdownPort));
xml.append(" ").append(XmlHandler.addTagValue("webAppName", webAppName));
xml.append(" ").append(XmlHandler.addTagValue("username", username));
xml.append(
Expand Down Expand Up @@ -435,6 +458,20 @@ public String getPort() {
/**
* @param port the port to set
*/
public void setShutdownPort(String port) {
this.shutdownPort = port;
}

/**
* @return the shutdown port
*/
public String getShutdownPort() {
return shutdownPort;
}

/**
* @param port the shutdown port to set
*/
public void setPort(String port) {
this.port = port;
}
Expand Down Expand Up @@ -1090,8 +1127,10 @@ public String sniffTransform(
public HopServer getClient() {
String pHostName = getHostname();
String pPort = getPort();
String shutdownPort = getShutdownPort();
String name = MessageFormat.format("Dynamic server [{0}:{1}]", pHostName, pPort);
HopServer client = new HopServer(name, pHostName, pPort, getUsername(), getPassword());
HopServer client =
new HopServer(name, pHostName, pPort, shutdownPort, getUsername(), getPassword());
client.setSslMode(isSslMode());
return client;
}
Expand Down
Loading