This is an automated email from the ASF dual-hosted git repository.
houyu pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/bigtop-manager.git
The following commit(s) were added to refs/heads/main by this push:
new 9c8c7b45 BIGTOP-4495: Add agent operations API (#263)
9c8c7b45 is described below
commit 9c8c7b4573f1ad2846669a10a8b08bdd884e2058
Author: Zhiguo Wu <[email protected]>
AuthorDate: Thu Sep 11 21:57:36 2025 +0800
BIGTOP-4495: Add agent operations API (#263)
---
.../src/main/resources/bin/agent.sh | 185 +++++++++++++++++++++
.../src/main/resources/bin/start.sh | 67 --------
.../manager/server/controller/HostController.java | 18 ++
.../manager/server/enums/ApiExceptionEnum.java | 2 +
.../bigtop/manager/server/enums/LocaleKeys.java | 2 +
.../bigtop/manager/server/service/HostService.java | 24 +++
.../server/service/impl/HostServiceImpl.java | 46 +++++
.../src/main/resources/bin/server.sh | 174 +++++++++++++++++++
.../src/main/resources/bin/start.sh | 65 --------
.../main/resources/i18n/messages_en_US.properties | 2 +
.../main/resources/i18n/messages_zh_CN.properties | 2 +
.../src/main/resources/scripts/setup-agent.sh | 2 +-
dev-support/docker/containers/build.sh | 2 +-
docs/en/deploy.md | 4 +-
docs/zh/deploy.md | 4 +-
15 files changed, 461 insertions(+), 138 deletions(-)
diff --git a/bigtop-manager-agent/src/main/resources/bin/agent.sh
b/bigtop-manager-agent/src/main/resources/bin/agent.sh
new file mode 100755
index 00000000..0e6bb54b
--- /dev/null
+++ b/bigtop-manager-agent/src/main/resources/bin/agent.sh
@@ -0,0 +1,185 @@
+#!/bin/bash
+#
+# 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
+#
+# https://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.
+#
+
+set -e
+
+BIN_DIR=$(dirname $0)
+BIGTOP_MANAGER_HOME=${BIGTOP_MANAGER_HOME:-$(cd $BIN_DIR/..; pwd)}
+PID_FILE="${BIGTOP_MANAGER_HOME}/bigtop-manager-agent.pid"
+
+source "${BIGTOP_MANAGER_HOME}/bin/env.sh"
+
+usage() {
+ echo "usage: $PROG {start|stop|restart} [--debug]"
+ echo " start - start the agent"
+ echo " stop - stop the agent"
+ echo " restart - restart the agent"
+ echo " --debug - enable debug mode"
+ echo " -h, --help"
+ exit 1
+}
+
+DEBUG="false"
+DOCKER="false"
+ACTION=""
+
+error () {
+ echo $1 >&2
+}
+
+# Parse command line arguments
+while [ $# -gt 0 ]; do
+ case "$1" in
+ start|stop|restart)
+ ACTION="$1"
+ shift;;
+ --debug)
+ echo "enable debug mode."
+ DEBUG="true"
+ shift;;
+ -h|--help)
+ usage
+ shift;;
+ *)
+ echo "Unknown argument: '$1'" 1>&2
+ usage;;
+ esac
+done
+
+# If no action specified, default to start for backward compatibility
+if [ -z "$ACTION" ]; then
+ ACTION="start"
+fi
+
+# Check if process is running
+is_running() {
+ if [ -f "$PID_FILE" ]; then
+ local pid=$(cat "$PID_FILE")
+ if ps -p "$pid" > /dev/null 2>&1; then
+ # Verify it's actually our agent process
+ if ps -p "$pid" -o args= | grep -q
"org.apache.bigtop.manager.agent.BigtopManagerAgent"; then
+ return 0
+ else
+ # PID file exists but process is not our agent, remove stale
PID file
+ rm -f "$PID_FILE"
+ fi
+ else
+ # PID file exists but process is not running, remove stale PID file
+ rm -f "$PID_FILE"
+ fi
+ fi
+
+ # No valid PID file, check if process is running and create PID file if
found
+ local running_pid=$(ps -ef | grep
"org.apache.bigtop.manager.agent.BigtopManagerAgent" | grep -v grep | awk
'{print $2}' | head -1)
+ if [ -n "$running_pid" ]; then
+ echo "$running_pid" > "$PID_FILE"
+ echo "Found running Bigtop Manager Agent process (PID: $running_pid),
created PID file"
+ return 0
+ fi
+
+ return 1
+}
+
+start_agent() {
+ if is_running; then
+ error "Bigtop Manager Agent is already running (PID: $(cat $PID_FILE))"
+ exit 1
+ fi
+
+ # Check and set default GRPC_PORT if not configured
+ if [ -z "$GRPC_PORT" ]; then
+ export GRPC_PORT="8835"
+ echo "GRPC_PORT not set, using default: 8835"
+ fi
+
+ echo "Starting Bigtop Manager Agent..."
+
+ JAVA_OPTS=${JAVA_OPTS:-"-server
-Duser.timezone=${SPRING_JACKSON_TIME_ZONE} -Xms4g -Xmx4g -Xmn2g
-XX:+IgnoreUnrecognizedVMOptions -XX:+PrintGCDateStamps -XX:+PrintGCDetails
-Xloggc:gc.log -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=dump.hprof"}
+
+ if [[ "$DOCKER" == "true" ]]; then
+ JAVA_OPTS="${JAVA_OPTS} -XX:-UseContainerSupport"
+ fi
+
+ if [[ "$DEBUG" == "true" ]]; then
+ JAVA_OPTS="${JAVA_OPTS}
-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5006"
+ fi
+
+ cd $BIGTOP_MANAGER_HOME
+
+ nohup $JAVA_CMD $JAVA_OPTS \
+ -cp "${BIGTOP_MANAGER_HOME}/conf":"${BIGTOP_MANAGER_HOME}/libs/*" \
+ org.apache.bigtop.manager.agent.BigtopManagerAgent > /dev/null 2>&1 &
+
+ echo $! > "$PID_FILE"
+ echo "Bigtop Manager Agent started successfully (PID: $!)"
+}
+
+stop_agent() {
+ if ! is_running; then
+ echo "Bigtop Manager Agent is not running"
+ return 0
+ fi
+
+ local pid=$(cat "$PID_FILE")
+ echo "Stopping Bigtop Manager Agent (PID: $pid)..."
+
+ # Try graceful shutdown first
+ kill "$pid" 2>/dev/null || true
+
+ # Wait for process to terminate
+ local count=0
+ while [ $count -lt 30 ]; do
+ if ! ps -p "$pid" > /dev/null 2>&1; then
+ break
+ fi
+ sleep 1
+ count=$((count + 1))
+ done
+
+ # Force kill if still running
+ if ps -p "$pid" > /dev/null 2>&1; then
+ echo "Force killing process..."
+ kill -9 "$pid" 2>/dev/null || true
+ fi
+
+ rm -f "$PID_FILE"
+ echo "Bigtop Manager Agent stopped successfully"
+}
+
+restart_agent() {
+ stop_agent
+ start_agent
+}
+
+# Execute the requested action
+case "$ACTION" in
+ start)
+ start_agent
+ ;;
+ stop)
+ stop_agent
+ ;;
+ restart)
+ restart_agent
+ ;;
+ *)
+ usage
+ ;;
+esac
diff --git a/bigtop-manager-agent/src/main/resources/bin/start.sh
b/bigtop-manager-agent/src/main/resources/bin/start.sh
deleted file mode 100755
index e95db26b..00000000
--- a/bigtop-manager-agent/src/main/resources/bin/start.sh
+++ /dev/null
@@ -1,67 +0,0 @@
-#!/bin/bash
-#
-# 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
-#
-# https://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.
-#
-
-set -e
-
-BIN_DIR=$(dirname $0)
-BIGTOP_MANAGER_HOME=${BIGTOP_MANAGER_HOME:-$(cd $BIN_DIR/..; pwd)}
-
-source "${BIGTOP_MANAGER_HOME}/bin/env.sh"
-
-usage() {
- echo "usage: $PROG [--debug]"
- echo " --debug - enable debug mode"
- echo " -h, --help"
- exit 1
-}
-
-DEBUG="false"
-DOCKER="false"
-
-while [ $# -gt 0 ]; do
- case "$1" in
- --debug)
- echo "enable debug mode."
- DEBUG="true"
- shift;;
- -h|--help)
- usage
- shift;;
- *)
- echo "Unknown argument: '$1'" 1>&2
- usage;;
- esac
-done
-
-JAVA_OPTS=${JAVA_OPTS:-"-server -Duser.timezone=${SPRING_JACKSON_TIME_ZONE}
-Xms4g -Xmx4g -Xmn2g -XX:+IgnoreUnrecognizedVMOptions -XX:+PrintGCDateStamps
-XX:+PrintGCDetails -Xloggc:gc.log -XX:+HeapDumpOnOutOfMemoryError
-XX:HeapDumpPath=dump.hprof"}
-
-if [[ "$DOCKER" == "true" ]]; then
- JAVA_OPTS="${JAVA_OPTS} -XX:-UseContainerSupport"
-fi
-
-if [[ "$DEBUG" == "true" ]]; then
- JAVA_OPTS="${JAVA_OPTS}
-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5006"
-fi
-
-cd $BIGTOP_MANAGER_HOME
-
-$JAVA_CMD $JAVA_OPTS \
- -cp "${BIGTOP_MANAGER_HOME}/conf":"${BIGTOP_MANAGER_HOME}/libs/*" \
- org.apache.bigtop.manager.agent.BigtopManagerAgent
diff --git
a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/controller/HostController.java
b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/controller/HostController.java
index e7b63b9f..6ffb121a 100644
---
a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/controller/HostController.java
+++
b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/controller/HostController.java
@@ -134,6 +134,24 @@ public class HostController {
return ResponseEntity.success(hostService.installedStatus());
}
+ @Operation(summary = "Start agent", description = "Start agent on the
host")
+ @PostMapping("/{id}/start-agent")
+ public ResponseEntity<Boolean> startAgent(@PathVariable("id") Long id) {
+ return ResponseEntity.success(hostService.startAgent(id));
+ }
+
+ @Operation(summary = "Stop agent", description = "Stop agent on the host")
+ @PostMapping("/{id}/stop-agent")
+ public ResponseEntity<Boolean> stopAgent(@PathVariable("id") Long id) {
+ return ResponseEntity.success(hostService.stopAgent(id));
+ }
+
+ @Operation(summary = "Restart agent", description = "Restart agent on the
host")
+ @PostMapping("/{id}/restart-agent")
+ public ResponseEntity<Boolean> restartAgent(@PathVariable("id") Long id) {
+ return ResponseEntity.success(hostService.restartAgent(id));
+ }
+
@Operation(summary = "check-duplicate", description = "check hostname
duplicate")
@PostMapping("/check-duplicate")
public ResponseEntity<Boolean> checkDuplicate(@RequestBody @Validated
HostReq hostReq) {
diff --git
a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/enums/ApiExceptionEnum.java
b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/enums/ApiExceptionEnum.java
index 20fe46b7..798b1281 100644
---
a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/enums/ApiExceptionEnum.java
+++
b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/enums/ApiExceptionEnum.java
@@ -33,6 +33,8 @@ public enum ApiExceptionEnum {
ORIGINAL_PASSWORD_SAME_AS_NEW_PASSWORD(10005,
LocaleKeys.ORIGINAL_PASSWORD_SAME_AS_NEW_PASSWORD),
TWO_PASSWORDS_NOT_MATCH(10006, LocaleKeys.TWO_PASSWORDS_NOT_MATCH),
ORIGINAL_PASSWORD_INCORRECT(10007, LocaleKeys.ORIGINAL_PASSWORD_INCORRECT),
+ OPERATION_SUCCESS(10008, LocaleKeys.OPERATION_SUCCESS),
+ OPERATION_FAILED(10009, LocaleKeys.OPERATION_FAILED),
// Cluster Exceptions -- 11000 ~ 11999
CLUSTER_NOT_FOUND(11000, LocaleKeys.CLUSTER_NOT_FOUND),
diff --git
a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/enums/LocaleKeys.java
b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/enums/LocaleKeys.java
index 30f53749..df63566a 100644
---
a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/enums/LocaleKeys.java
+++
b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/enums/LocaleKeys.java
@@ -37,6 +37,8 @@ public enum LocaleKeys {
ORIGINAL_PASSWORD_SAME_AS_NEW_PASSWORD("original.password.same.as.new.password"),
TWO_PASSWORDS_NOT_MATCH("two.passwords.not.match"),
ORIGINAL_PASSWORD_INCORRECT("original.password.incorrect"),
+ OPERATION_SUCCESS("operation.success"),
+ OPERATION_FAILED("operation.failed"),
CLUSTER_NOT_FOUND("cluster.not.found"),
CLUSTER_EXISTS("cluster.exists"),
diff --git
a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/HostService.java
b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/HostService.java
index 8ddc391f..c4b8bab0 100644
---
a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/HostService.java
+++
b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/HostService.java
@@ -103,6 +103,30 @@ public interface HostService {
*/
List<InstalledStatusVO> installedStatus();
+ /**
+ * Start agent on the host
+ *
+ * @param hostId host id
+ * @return true if started successfully
+ */
+ Boolean startAgent(Long hostId);
+
+ /**
+ * Stop agent on the host
+ *
+ * @param hostId host id
+ * @return true if stopped successfully
+ */
+ Boolean stopAgent(Long hostId);
+
+ /**
+ * Restart agent on the host
+ *
+ * @param hostId host id
+ * @return true if restarted successfully
+ */
+ Boolean restartAgent(Long hostId);
+
/**
* validate host exists
* @param hostDTO hostnames
diff --git
a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/HostServiceImpl.java
b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/HostServiceImpl.java
index e726ae9b..bcb49ed2 100644
---
a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/HostServiceImpl.java
+++
b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/HostServiceImpl.java
@@ -261,6 +261,21 @@ public class HostServiceImpl implements HostService {
return installedStatus;
}
+ @Override
+ public Boolean startAgent(Long hostId) {
+ return execAgentScript(hostId, "start");
+ }
+
+ @Override
+ public Boolean stopAgent(Long hostId) {
+ return execAgentScript(hostId, "stop");
+ }
+
+ @Override
+ public Boolean restartAgent(Long hostId) {
+ return execAgentScript(hostId, "restart");
+ }
+
@Override
public Boolean checkDuplicate(HostDTO hostDTO) {
List<HostPO> existsHostList =
hostDao.findAllByHostnames(hostDTO.getHostnames());
@@ -308,6 +323,37 @@ public class HostServiceImpl implements HostService {
installedStatusVO.setStatus(InstalledStatusEnum.SUCCESS);
}
+ private Boolean execAgentScript(Long hostId, String action) {
+ HostPO hostPO = hostDao.findById(hostId);
+ if (hostPO == null) {
+ throw new ApiException(ApiExceptionEnum.HOST_NOT_FOUND);
+ }
+
+ HostDTO hostDTO = HostConverter.INSTANCE.fromPO2DTO(hostPO);
+ String path = hostDTO.getAgentDir();
+ String hostname = hostDTO.getHostname();
+ int grpcPort = hostDTO.getGrpcPort();
+
+ String command = path + "/bigtop-manager-agent/bin/agent.sh " + action;
+ command = "export GRPC_PORT=" + grpcPort + " ; " + command;
+
+ ShellResult result = execCommandOnRemoteHost(hostDTO, hostname,
command);
+ if (result.getExitCode() != MessageConstants.SUCCESS_CODE) {
+ log.error("Unable to {} agent, hostname: {}, msg: {}", action,
hostname, result);
+ throw new ApiException(ApiExceptionEnum.OPERATION_FAILED);
+ }
+
+ // Update host status
+ if (action.equals("stop")) {
+ hostPO.setStatus(HealthyStatusEnum.UNHEALTHY.getCode());
+ } else {
+ hostPO.setStatus(HealthyStatusEnum.HEALTHY.getCode());
+ }
+
+ hostDao.updateById(hostPO);
+ return true;
+ }
+
private ShellResult execCommandOnRemoteHost(HostDTO hostDTO, String
hostname, String command) {
HostAuthTypeEnum authType =
HostAuthTypeEnum.fromCode(hostDTO.getAuthType());
try {
diff --git a/bigtop-manager-server/src/main/resources/bin/server.sh
b/bigtop-manager-server/src/main/resources/bin/server.sh
new file mode 100755
index 00000000..6de9d512
--- /dev/null
+++ b/bigtop-manager-server/src/main/resources/bin/server.sh
@@ -0,0 +1,174 @@
+#!/bin/bash
+#
+# 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
+#
+# https://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.
+#
+
+set -e
+
+BIN_DIR=$(dirname $0)
+BIGTOP_MANAGER_HOME=${BIGTOP_MANAGER_HOME:-$(cd $BIN_DIR/..; pwd)}
+PID_FILE="${BIGTOP_MANAGER_HOME}/bigtop-manager-server.pid"
+
+source "${BIGTOP_MANAGER_HOME}/bin/env.sh"
+
+usage() {
+ echo "usage: $PROG {start|stop|restart} [--debug]"
+ echo " start - start the server"
+ echo " stop - stop the server"
+ echo " restart - restart the server"
+ echo " --debug - enable debug mode"
+ echo " -h, --help"
+ exit 1
+}
+
+DEBUG="false"
+DOCKER="false"
+ACTION=""
+
+while [ $# -gt 0 ]; do
+ case "$1" in
+ start|stop|restart)
+ ACTION="$1"
+ shift;;
+ --debug)
+ echo "enable debug mode."
+ DEBUG="true"
+ shift;;
+ -h|--help)
+ usage
+ shift;;
+ *)
+ echo "Unknown argument: '$1'" 1>&2
+ usage;;
+ esac
+done
+
+# If no action specified, default to start for backward compatibility
+if [ -z "$ACTION" ]; then
+ ACTION="start"
+fi
+
+# Check if process is running
+is_running() {
+ if [ -f "$PID_FILE" ]; then
+ local pid=$(cat "$PID_FILE")
+ if ps -p "$pid" > /dev/null 2>&1; then
+ # Verify it's actually our server process
+ if ps -p "$pid" -o args= | grep -q
"org.apache.bigtop.manager.server.BigtopManagerServer"; then
+ return 0
+ else
+ # PID file exists but process is not our server, remove stale
PID file
+ rm -f "$PID_FILE"
+ fi
+ else
+ # PID file exists but process is not running, remove stale PID file
+ rm -f "$PID_FILE"
+ fi
+ fi
+
+ # No valid PID file, check if process is running and create PID file if
found
+ local running_pid=$(ps -ef | grep
"org.apache.bigtop.manager.server.BigtopManagerServer" | grep -v grep | awk
'{print $2}' | head -1)
+ if [ -n "$running_pid" ]; then
+ echo "$running_pid" > "$PID_FILE"
+ echo "Found running Bigtop Manager Server process (PID: $running_pid),
created PID file"
+ return 0
+ fi
+
+ return 1
+}
+
+start_server() {
+ if is_running; then
+ echo "Bigtop Manager Server is already running (PID: $(cat $PID_FILE))"
+ exit 1
+ fi
+
+ echo "Starting Bigtop Manager Server..."
+
+ JAVA_OPTS=${JAVA_OPTS:-"-server
-Duser.timezone=${SPRING_JACKSON_TIME_ZONE} -Xms4g -Xmx4g -Xmn2g
-XX:+IgnoreUnrecognizedVMOptions -XX:+PrintGCDateStamps -XX:+PrintGCDetails
-Xloggc:gc.log -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=dump.hprof"}
+
+ if [[ "$DOCKER" == "true" ]]; then
+ JAVA_OPTS="${JAVA_OPTS} -XX:-UseContainerSupport"
+ fi
+
+ if [[ "$DEBUG" == "true" ]]; then
+ JAVA_OPTS="${JAVA_OPTS}
-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005"
+ fi
+
+ cd $BIGTOP_MANAGER_HOME
+
+ nohup $JAVA_CMD $JAVA_OPTS \
+ -cp "${BIGTOP_MANAGER_HOME}/conf":"${BIGTOP_MANAGER_HOME}/libs/*" \
+ org.apache.bigtop.manager.server.BigtopManagerServer > /dev/null 2>&1 &
+
+ echo $! > "$PID_FILE"
+ echo "Bigtop Manager Server started successfully (PID: $!)"
+}
+
+stop_server() {
+ if ! is_running; then
+ echo "Bigtop Manager Server is not running"
+ return 0
+ fi
+
+ local pid=$(cat "$PID_FILE")
+ echo "Stopping Bigtop Manager Server (PID: $pid)..."
+
+ # Try graceful shutdown first
+ kill "$pid" 2>/dev/null || true
+
+ # Wait for process to terminate
+ local count=0
+ while [ $count -lt 30 ]; do
+ if ! ps -p "$pid" > /dev/null 2>&1; then
+ break
+ fi
+ sleep 1
+ count=$((count + 1))
+ done
+
+ # Force kill if still running
+ if ps -p "$pid" > /dev/null 2>&1; then
+ echo "Force killing process..."
+ kill -9 "$pid" 2>/dev/null || true
+ fi
+
+ rm -f "$PID_FILE"
+ echo "Bigtop Manager Server stopped successfully"
+}
+
+restart_server() {
+ stop_server
+ start_server
+}
+
+# Execute the requested action
+case "$ACTION" in
+ start)
+ start_server
+ ;;
+ stop)
+ stop_server
+ ;;
+ restart)
+ restart_server
+ ;;
+ *)
+ usage
+ ;;
+esac
diff --git a/bigtop-manager-server/src/main/resources/bin/start.sh
b/bigtop-manager-server/src/main/resources/bin/start.sh
deleted file mode 100755
index 507d4eae..00000000
--- a/bigtop-manager-server/src/main/resources/bin/start.sh
+++ /dev/null
@@ -1,65 +0,0 @@
-#!/bin/bash
-#
-# 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
-#
-# https://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.
-#
-
-BIN_DIR=$(dirname $0)
-BIGTOP_MANAGER_HOME=${BIGTOP_MANAGER_HOME:-$(cd $BIN_DIR/..; pwd)}
-
-source "${BIGTOP_MANAGER_HOME}/bin/env.sh"
-
-usage() {
- echo "usage: $PROG [--debug]"
- echo " --debug - enable debug mode"
- echo " -h, --help"
- exit 1
-}
-
-DEBUG="false"
-DOCKER="false"
-
-while [ $# -gt 0 ]; do
- case "$1" in
- --debug)
- echo "enable debug mode."
- DEBUG="true"
- shift;;
- -h|--help)
- usage
- shift;;
- *)
- echo "Unknown argument: '$1'" 1>&2
- usage;;
- esac
-done
-
-JAVA_OPTS=${JAVA_OPTS:-"-server -Duser.timezone=${SPRING_JACKSON_TIME_ZONE}
-Xms4g -Xmx4g -Xmn2g -XX:+IgnoreUnrecognizedVMOptions -XX:+PrintGCDateStamps
-XX:+PrintGCDetails -Xloggc:gc.log -XX:+HeapDumpOnOutOfMemoryError
-XX:HeapDumpPath=dump.hprof"}
-
-if [[ "$DOCKER" == "true" ]]; then
- JAVA_OPTS="${JAVA_OPTS} -XX:-UseContainerSupport"
-fi
-
-if [[ "$DEBUG" == "true" ]]; then
- JAVA_OPTS="${JAVA_OPTS}
-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005"
-fi
-
-cd $BIGTOP_MANAGER_HOME
-
-$JAVA_CMD $JAVA_OPTS \
- -cp "${BIGTOP_MANAGER_HOME}/conf":"${BIGTOP_MANAGER_HOME}/libs/*" \
- org.apache.bigtop.manager.server.BigtopManagerServer
diff --git
a/bigtop-manager-server/src/main/resources/i18n/messages_en_US.properties
b/bigtop-manager-server/src/main/resources/i18n/messages_en_US.properties
index 2540c225..f17fa31e 100644
--- a/bigtop-manager-server/src/main/resources/i18n/messages_en_US.properties
+++ b/bigtop-manager-server/src/main/resources/i18n/messages_en_US.properties
@@ -31,6 +31,8 @@ password.not.empty=The password cannot be empty
original.password.same.as.new.password=Original password is same as new
password
two.passwords.not.match=Two passwords not match
original.password.incorrect=Original password is incorrect
+operation.success=Operation succeeded
+operation.failed=Operation failed, please check the log
cluster.not.found=Cluster not exist
cluster.exists=Cluster already exists
diff --git
a/bigtop-manager-server/src/main/resources/i18n/messages_zh_CN.properties
b/bigtop-manager-server/src/main/resources/i18n/messages_zh_CN.properties
index 2092345b..edfe6d4a 100644
--- a/bigtop-manager-server/src/main/resources/i18n/messages_zh_CN.properties
+++ b/bigtop-manager-server/src/main/resources/i18n/messages_zh_CN.properties
@@ -31,6 +31,8 @@ password.not.empty=密码不能为空
original.password.same.as.new.password=原始密码不能与新密码相同
two.passwords.not.match=两次密码输入不一致
original.password.incorrect=原始密码错误
+operation.success=操作成功
+operation.failed=操作失败,请查看日志
cluster.not.found=集群不存在
cluster.exists=集群已存在
diff --git a/bigtop-manager-server/src/main/resources/scripts/setup-agent.sh
b/bigtop-manager-server/src/main/resources/scripts/setup-agent.sh
index a7bdaef6..c453c0cb 100644
--- a/bigtop-manager-server/src/main/resources/scripts/setup-agent.sh
+++ b/bigtop-manager-server/src/main/resources/scripts/setup-agent.sh
@@ -123,7 +123,7 @@ start() {
info "Prepare to start agent"
if ! pgrep -f "${PROCESS_NAME}" > /dev/null; then
info "Starting agent"
- nohup ${TARGET_DIR}/bin/start.sh --debug > /dev/null
2>>setup-agent.log &
+ nohup ${TARGET_DIR}/bin/agent.sh start --debug > /dev/null
2>>setup-agent.log &
sleep 10
if ! pgrep -f "${PROCESS_NAME}" > /dev/null; then
error "Failed to start agent, please check the log"
diff --git a/dev-support/docker/containers/build.sh
b/dev-support/docker/containers/build.sh
index 3abc352a..88131b36 100755
--- a/dev-support/docker/containers/build.sh
+++ b/dev-support/docker/containers/build.sh
@@ -112,7 +112,7 @@ create_container() {
docker exec ${container} bash -c "PGPASSWORD=postgres psql -h
bm-postgres -p5432 -U postgres -d bigtop_manager -f
/opt/bigtop-manager-server/ddl/PostgreSQL-DDL-CREATE.sql"
docker exec ${container} bash -c "sed -i
's/localhost:5432/bm-postgres:5432/'
/opt/bigtop-manager-server/conf/application.yml"
fi
- docker exec ${container} bash -c "nohup /bin/bash
/opt/bigtop-manager-server/bin/start.sh --debug > /dev/null 2>&1 &"
+ docker exec ${container} bash -c "nohup /bin/bash
/opt/bigtop-manager-server/bin/server.sh start --debug > /dev/null 2>&1 &"
fi
log "All Service Started!!!"
done
diff --git a/docs/en/deploy.md b/docs/en/deploy.md
index c267f058..1cd2b2bb 100644
--- a/docs/en/deploy.md
+++ b/docs/en/deploy.md
@@ -69,10 +69,10 @@ wget
https://maven.aliyun.com/repository/central/com/mysql/mysql-connector-j/8.0
cd /opt/bigtop-manager-server
# Start service
-./bin/start.sh
+./bin/server.sh start
# Or run in background
-nohup bin/start.sh > /dev/null 2>&1 &
+nohup bin/server.sh start > /dev/null 2>&1 &
```
## 7. Admin Page
diff --git a/docs/zh/deploy.md b/docs/zh/deploy.md
index 44b76c32..806db705 100644
--- a/docs/zh/deploy.md
+++ b/docs/zh/deploy.md
@@ -69,10 +69,10 @@ wget
https://maven.aliyun.com/repository/central/com/mysql/mysql-connector-j/8.0
cd /opt/bigtop-manager-server
# 启动服务
-./bin/start.sh
+./bin/server.sh start
# 或者在后台启动服务
-nohup bin/start.sh > /dev/null 2>&1 &
+nohup bin/server.sh start > /dev/null 2>&1 &
```
## 访问管理页面