This is an automated email from the ASF dual-hosted git repository.

yongzao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/master by this push:
     new 83addf9871a Set both JAVA_HOME and PATH environment for 
daemon-services (#17370)
83addf9871a is described below

commit 83addf9871a37c442494c2057976178626c41625
Author: Yongzao <[email protected]>
AuthorDate: Fri Mar 27 15:07:07 2026 +0800

    Set both JAVA_HOME and PATH environment for daemon-services (#17370)
---
 scripts/tools/ops/daemon-confignode.sh | 34 ++++++++++++++++++++++++++++++++--
 scripts/tools/ops/daemon-datanode.sh   | 34 ++++++++++++++++++++++++++++++++--
 2 files changed, 64 insertions(+), 4 deletions(-)

diff --git a/scripts/tools/ops/daemon-confignode.sh 
b/scripts/tools/ops/daemon-confignode.sh
index 9bdb23377e6..f89af831711 100644
--- a/scripts/tools/ops/daemon-confignode.sh
+++ b/scripts/tools/ops/daemon-confignode.sh
@@ -25,13 +25,14 @@ if [ ! -d "$SYSTEMD_DIR" ]; then
     exit 1  # Exit with an error status
 fi
 
-if [ -z "$JAVA_HOME" ]; then
-    echo "JAVA_HOME is not set. Please set the JAVA_HOME environment variable."
+if ! java --version >/dev/null 2>&1; then
+    echo "java command is not available. Please install Java or ensure it is 
in PATH."
     exit 1
 fi
 
 FILE_NAME=$SYSTEMD_DIR/iotdb-confignode.service
 
+if [ -z "$JAVA_HOME" ]; then
 cat > "$FILE_NAME" <<EOF
 [Unit]
 Description=iotdb-confignode
@@ -46,6 +47,34 @@ Type=simple
 User=root
 Group=root
 Environment=JAVA_HOME=$JAVA_HOME
+Environment=PATH=$JAVA_HOME/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
+ExecStart=$IOTDB_SBIN_HOME/start-confignode.sh
+ExecStop=$IOTDB_SBIN_HOME/stop-confignode.sh
+Restart=on-failure
+SuccessExitStatus=143
+RestartSec=5
+StartLimitInterval=600s
+StartLimitBurst=3
+RestartPreventExitStatus=SIGKILL
+
+[Install]
+WantedBy=multi-user.target
+EOF
+else
+cat > "$FILE_NAME" <<EOF
+[Unit]
+Description=iotdb-confignode
+Documentation=https://iotdb.apache.org/
+After=network.target
+
+[Service]
+StandardOutput=null
+StandardError=null
+LimitNOFILE=65536
+Type=simple
+User=root
+Group=root
+Environment=PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
 ExecStart=$IOTDB_SBIN_HOME/start-confignode.sh
 ExecStop=$IOTDB_SBIN_HOME/stop-confignode.sh
 Restart=on-failure
@@ -58,6 +87,7 @@ RestartPreventExitStatus=SIGKILL
 [Install]
 WantedBy=multi-user.target
 EOF
+fi
 
 echo "Daemon service of IoTDB ConfigNode has been successfully registered."
 
diff --git a/scripts/tools/ops/daemon-datanode.sh 
b/scripts/tools/ops/daemon-datanode.sh
index 5c5963c2bf5..06e80d61bac 100644
--- a/scripts/tools/ops/daemon-datanode.sh
+++ b/scripts/tools/ops/daemon-datanode.sh
@@ -25,13 +25,14 @@ if [ ! -d "$SYSTEMD_DIR" ]; then
     exit 1  # Exit with an error status
 fi
 
-if [ -z "$JAVA_HOME" ]; then
-    echo "JAVA_HOME is not set. Please set the JAVA_HOME environment variable."
+if ! java --version >/dev/null 2>&1; then
+    echo "java command is not available. Please install Java or ensure it is 
in PATH."
     exit 1
 fi
 
 FILE_NAME=$SYSTEMD_DIR/iotdb-datanode.service
 
+if [ -z "$JAVA_HOME" ]; then
 cat > "$FILE_NAME" <<EOF
 [Unit]
 Description=iotdb-datanode
@@ -46,6 +47,34 @@ Type=simple
 User=root
 Group=root
 Environment=JAVA_HOME=$JAVA_HOME
+Environment=PATH=$JAVA_HOME/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
+ExecStart=$IOTDB_SBIN_HOME/start-datanode.sh
+ExecStop=$IOTDB_SBIN_HOME/stop-datanode.sh
+Restart=on-failure
+SuccessExitStatus=143
+RestartSec=5
+StartLimitInterval=600s
+StartLimitBurst=3
+RestartPreventExitStatus=SIGKILL
+
+[Install]
+WantedBy=multi-user.target
+EOF
+else
+cat > "$FILE_NAME" <<EOF
+[Unit]
+Description=iotdb-datanode
+Documentation=https://iotdb.apache.org/
+After=network.target
+
+[Service]
+StandardOutput=null
+StandardError=null
+LimitNOFILE=65536
+Type=simple
+User=root
+Group=root
+Environment=PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
 ExecStart=$IOTDB_SBIN_HOME/start-datanode.sh
 ExecStop=$IOTDB_SBIN_HOME/stop-datanode.sh
 Restart=on-failure
@@ -58,6 +87,7 @@ RestartPreventExitStatus=SIGKILL
 [Install]
 WantedBy=multi-user.target
 EOF
+fi
 
 echo "Daemon service of IoTDB DataNode has been successfully registered."
 

Reply via email to