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 2c903b01328 [AINode] Support register as system service (#17138)
2c903b01328 is described below
commit 2c903b01328500a1d0de6b4d9068b9c43b97ff78
Author: Yongzao <[email protected]>
AuthorDate: Wed Feb 4 18:19:21 2026 +0800
[AINode] Support register as system service (#17138)
---
iotdb-core/ainode/ainode.xml | 9 +++++++
.../iotdb/ainode/core/inference/pool_controller.py | 13 +++++++++-
.../iotdb/ainode/core/manager/inference_manager.py | 1 +
iotdb-core/ainode/iotdb/ainode/core/rpc/handler.py | 3 ++-
scripts/sbin/start-ainode.sh | 2 +-
scripts/sbin/stop-ainode.sh | 2 +-
.../ops/{daemon-datanode.sh => daemon-ainode.sh} | 28 ++++++++++------------
scripts/tools/ops/daemon-confignode.sh | 3 ++-
scripts/tools/ops/daemon-datanode.sh | 3 ++-
9 files changed, 42 insertions(+), 22 deletions(-)
diff --git a/iotdb-core/ainode/ainode.xml b/iotdb-core/ainode/ainode.xml
index 6de635c1338..b47cbeb4a79 100644
--- a/iotdb-core/ainode/ainode.xml
+++ b/iotdb-core/ainode/ainode.xml
@@ -69,5 +69,14 @@
</includes>
<fileMode>0755</fileMode>
</fileSet>
+ <fileSet>
+ <directory>${project.basedir}/../../scripts/tools/ops</directory>
+ <outputDirectory>tools/ops</outputDirectory>
+ <includes>
+ <include>*ainode.*</include>
+ <include>**/*ainode.*</include>
+ </includes>
+ <fileMode>0755</fileMode>
+ </fileSet>
</fileSets>
</assembly>
diff --git a/iotdb-core/ainode/iotdb/ainode/core/inference/pool_controller.py
b/iotdb-core/ainode/iotdb/ainode/core/inference/pool_controller.py
index 5a6db12edde..f4b3d23d36f 100644
--- a/iotdb-core/ainode/iotdb/ainode/core/inference/pool_controller.py
+++ b/iotdb-core/ainode/iotdb/ainode/core/inference/pool_controller.py
@@ -20,6 +20,7 @@ import queue
import random
import threading
from concurrent.futures import wait
+from queue import Empty
from typing import Dict, Optional
import torch
@@ -176,9 +177,16 @@ class PoolController:
def _worker_loop(self):
while not self._stop_event.is_set():
- task = self._task_queue.get()
+ try:
+ task = self._task_queue.get(timeout=1)
+ except Empty:
+ # Ignore Empty exception and continue the loop
+ continue
if task is None:
self._task_queue.task_done()
+ logger.info(
+ "PoolController received task None, the worker loop is
existed."
+ )
break
task_fn, args, kwargs = task
try:
@@ -519,9 +527,12 @@ class PoolController:
self._task_queue.put(None)
self._pool_control_worker_thread.join()
self._executor.close()
+ logger.info(f"PoolController stopped its task executor.")
# shutdown pool instances
# TODO: pool instances can be shutdown in parallel
for inner in self._request_pool_map.values():
for group in inner.values():
group.shutdown()
+
+ logger.info("The PoolController has been stopped.")
diff --git a/iotdb-core/ainode/iotdb/ainode/core/manager/inference_manager.py
b/iotdb-core/ainode/iotdb/ainode/core/manager/inference_manager.py
index 180cc00ff49..2ad25ad0529 100644
--- a/iotdb-core/ainode/iotdb/ainode/core/manager/inference_manager.py
+++ b/iotdb-core/ainode/iotdb/ainode/core/manager/inference_manager.py
@@ -292,3 +292,4 @@ class InferenceManager:
while not self._result_queue.empty():
self._result_queue.get_nowait()
self._result_queue.close()
+ logger.info("The Inference Manager has been stopped.")
diff --git a/iotdb-core/ainode/iotdb/ainode/core/rpc/handler.py
b/iotdb-core/ainode/iotdb/ainode/core/rpc/handler.py
index e303a2c4c35..e3b5b49e057 100644
--- a/iotdb-core/ainode/iotdb/ainode/core/rpc/handler.py
+++ b/iotdb-core/ainode/iotdb/ainode/core/rpc/handler.py
@@ -58,8 +58,9 @@ class AINodeRPCServiceHandler(IAINodeRPCService.Iface):
# ==================== Cluster Management ====================
def stop(self):
- logger.info("Stopping the RPC service handler of IoTDB-AINode...")
+ logger.info("Stopping the RPC handler of IoTDB-AINode...")
self._inference_manager.stop()
+ logger.info("The RPC handler of IoTDB-AINode exited.")
def stopAINode(self) -> TSStatus:
self._ainode.stop()
diff --git a/scripts/sbin/start-ainode.sh b/scripts/sbin/start-ainode.sh
index 454a0389c38..3012171c5f9 100644
--- a/scripts/sbin/start-ainode.sh
+++ b/scripts/sbin/start-ainode.sh
@@ -51,5 +51,5 @@ if [ "$daemon_mode" = true ]; then
echo AINode started in background
else
echo Starting AINode...
- $ain_ainode_executable start
+ exec "$ain_ainode_executable" start
fi
diff --git a/scripts/sbin/stop-ainode.sh b/scripts/sbin/stop-ainode.sh
index 74d27f3b9fc..58ca4d98eb2 100644
--- a/scripts/sbin/stop-ainode.sh
+++ b/scripts/sbin/stop-ainode.sh
@@ -73,7 +73,7 @@ if [ -z "$PID" ]; then
fi
exit 1
elif [[ "${PID_VERIFY}" =~ ${PID} ]]; then
- kill -s TERM "$PID"
+ kill -s TERM -- "-$PID"
echo "Stop AINode, PID:" "$PID"
else
echo "No AINode to stop"
diff --git a/scripts/tools/ops/daemon-datanode.sh
b/scripts/tools/ops/daemon-ainode.sh
similarity index 68%
copy from scripts/tools/ops/daemon-datanode.sh
copy to scripts/tools/ops/daemon-ainode.sh
index 10dc5b4ef09..2d25222f92b 100644
--- a/scripts/tools/ops/daemon-datanode.sh
+++ b/scripts/tools/ops/daemon-ainode.sh
@@ -17,7 +17,7 @@
# specific language governing permissions and limitations
# under the License.
#
-IOTDB_SBIN_HOME="$(cd "`dirname "$0"`"/../../sbin; pwd)"
+IOTDB_AINODE_SBIN_HOME="$(cd "`dirname "$0"`"/../../sbin; pwd)"
SYSTEMD_DIR="/etc/systemd/system"
if [ ! -d "$SYSTEMD_DIR" ]; then
@@ -25,16 +25,11 @@ 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."
- exit 1
-fi
-
-FILE_NAME=$SYSTEMD_DIR/iotdb-datanode.service
+FILE_NAME=$SYSTEMD_DIR/iotdb-ainode.service
cat > "$FILE_NAME" <<EOF
[Unit]
-Description=iotdb-datanode
+Description=iotdb-ainode
Documentation=https://iotdb.apache.org/
After=network.target
@@ -45,34 +40,35 @@ LimitNOFILE=65536
Type=simple
User=root
Group=root
-Environment=JAVA_HOME=$JAVA_HOME
-ExecStart=$IOTDB_SBIN_HOME/start-datanode.sh
+ExecStart=$IOTDB_AINODE_SBIN_HOME/start-ainode.sh
+ExecStop=/bin/kill -TERM -\$MAINPID
Restart=on-failure
SuccessExitStatus=143
RestartSec=5
StartLimitInterval=600s
StartLimitBurst=3
RestartPreventExitStatus=SIGKILL
+TimeoutStopSec=60s
[Install]
WantedBy=multi-user.target
EOF
-echo "Daemon service of IoTDB DataNode has been successfully registered."
+echo "Daemon service of IoTDB AINode has been successfully registered."
systemctl daemon-reload
echo
-echo "Do you want to execute 'systemctl start iotdb-datanode'? y/n (default y)"
+echo "Do you want to execute 'systemctl start iotdb-ainode'? y/n (default y)"
read -r START_SERVICE
if [[ -z "$START_SERVICE" || "$START_SERVICE" =~ ^[Yy]$ ]]; then
- "${IOTDB_SBIN_HOME}"/sbin/stop-datanode.sh >/dev/null 2>&1 &
- systemctl start iotdb-datanode
+ "${IOTDB_AINODE_SBIN_HOME}"/stop-ainode.sh >/dev/null 2>&1 &
+ systemctl start iotdb-ainode
echo "Executed successfully."
fi
echo
-echo "Do you want to execute 'systemctl enable iotdb-datanode' to start at
boot? y/n (default y)"
+echo "Do you want to execute 'systemctl enable iotdb-ainode' to start at boot?
y/n (default y)"
read -r ADD_STARTUP
if [[ -z "$ADD_STARTUP" || "$ADD_STARTUP" =~ ^[Yy]$ ]]; then
- systemctl enable iotdb-datanode >/dev/null 2>&1
+ systemctl enable iotdb-ainode >/dev/null 2>&1
echo "Executed successfully."
fi
\ No newline at end of file
diff --git a/scripts/tools/ops/daemon-confignode.sh
b/scripts/tools/ops/daemon-confignode.sh
index 8e1d0d9cd94..9bdb23377e6 100644
--- a/scripts/tools/ops/daemon-confignode.sh
+++ b/scripts/tools/ops/daemon-confignode.sh
@@ -47,6 +47,7 @@ User=root
Group=root
Environment=JAVA_HOME=$JAVA_HOME
ExecStart=$IOTDB_SBIN_HOME/start-confignode.sh
+ExecStop=$IOTDB_SBIN_HOME/stop-confignode.sh
Restart=on-failure
SuccessExitStatus=143
RestartSec=5
@@ -65,7 +66,7 @@ echo
echo "Do you want to execute 'systemctl start iotdb-confignode'? y/n (default
y)"
read -r START_SERVICE
if [[ -z "$START_SERVICE" || "$START_SERVICE" =~ ^[Yy]$ ]]; then
- "${IOTDB_SBIN_HOME}"/sbin/stop-confignode.sh >/dev/null 2>&1 &
+ "${IOTDB_SBIN_HOME}"/stop-confignode.sh >/dev/null 2>&1 &
systemctl start iotdb-confignode
echo "Executed successfully."
fi
diff --git a/scripts/tools/ops/daemon-datanode.sh
b/scripts/tools/ops/daemon-datanode.sh
index 10dc5b4ef09..5c5963c2bf5 100644
--- a/scripts/tools/ops/daemon-datanode.sh
+++ b/scripts/tools/ops/daemon-datanode.sh
@@ -47,6 +47,7 @@ User=root
Group=root
Environment=JAVA_HOME=$JAVA_HOME
ExecStart=$IOTDB_SBIN_HOME/start-datanode.sh
+ExecStop=$IOTDB_SBIN_HOME/stop-datanode.sh
Restart=on-failure
SuccessExitStatus=143
RestartSec=5
@@ -65,7 +66,7 @@ echo
echo "Do you want to execute 'systemctl start iotdb-datanode'? y/n (default y)"
read -r START_SERVICE
if [[ -z "$START_SERVICE" || "$START_SERVICE" =~ ^[Yy]$ ]]; then
- "${IOTDB_SBIN_HOME}"/sbin/stop-datanode.sh >/dev/null 2>&1 &
+ "${IOTDB_SBIN_HOME}"/stop-datanode.sh >/dev/null 2>&1 &
systemctl start iotdb-datanode
echo "Executed successfully."
fi