Skip to content
Open
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
9 changes: 9 additions & 0 deletions iotdb-core/ainode/ainode.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
13 changes: 12 additions & 1 deletion iotdb-core/ainode/iotdb/ainode/core/inference/pool_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import random
import threading
from concurrent.futures import wait
from queue import Empty
from typing import Dict, Optional

import torch
Expand Down Expand Up @@ -176,9 +177,16 @@ def show_loaded_models(

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:
Expand Down Expand Up @@ -519,9 +527,12 @@ def stop(self):
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.")
Original file line number Diff line number Diff line change
Expand Up @@ -292,3 +292,4 @@ def stop(self):
while not self._result_queue.empty():
self._result_queue.get_nowait()
self._result_queue.close()
logger.info("The Inference Manager has been stopped.")
3 changes: 2 additions & 1 deletion iotdb-core/ainode/iotdb/ainode/core/rpc/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@ def __init__(self, ainode):
# ==================== 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()
Expand Down
74 changes: 74 additions & 0 deletions scripts/tools/ops/daemon-ainode.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/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
#
# 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.
#
IOTDB_AINODE_SBIN_HOME="$(cd "`dirname "$0"`"/../../sbin; pwd)"
SYSTEMD_DIR="/etc/systemd/system"

if [ ! -d "$SYSTEMD_DIR" ]; then
echo "Current system can't support systemd"
exit 1 # Exit with an error status
fi

FILE_NAME=$SYSTEMD_DIR/iotdb-ainode.service

cat > "$FILE_NAME" <<EOF
[Unit]
Description=iotdb-ainode
Documentation=https://iotdb.apache.org/
After=network.target

[Service]
StandardOutput=null
StandardError=null
LimitNOFILE=65536
Type=simple
User=root
Group=root
ExecStart=$IOTDB_AINODE_SBIN_HOME/start-ainode.sh
ExecStop=$IOTDB_AINODE_SBIN_HOME/stop-ainode.sh
Restart=on-failure
SuccessExitStatus=143
RestartSec=5
StartLimitInterval=600s
StartLimitBurst=3
RestartPreventExitStatus=SIGKILL
TimeoutStopSec=5s

[Install]
WantedBy=multi-user.target
EOF

echo "Daemon service of IoTDB AINode has been successfully registered."

systemctl daemon-reload
echo
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_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-ainode' to start at boot? y/n (default y)"
read -r ADD_STARTUP
if [[ -z "$ADD_STARTUP" || "$ADD_STARTUP" =~ ^[Yy]$ ]]; then
systemctl enable iotdb-ainode >/dev/null 2>&1
echo "Executed successfully."
fi
3 changes: 2 additions & 1 deletion scripts/tools/ops/daemon-confignode.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion scripts/tools/ops/daemon-datanode.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Loading