update README and SERVICE

This commit is contained in:
2026-04-20 20:59:51 +07:00
parent 4b1fd185d7
commit 89fbac3177
5 changed files with 640 additions and 27 deletions
+29 -4
View File
@@ -18,14 +18,31 @@ if [ "$EUID" -ne 0 ]; then
exit 1
fi
# Tạo file config model mặc định nếu chưa có
if [ ! -f "service_config.txt" ]; then
# Hỏi cấu hình
echo "Cấu hình service:"
echo
# Port
read -p "Port (mặc định 8000): " SERVICE_PORT
SERVICE_PORT=${SERVICE_PORT:-8000}
# Model path (tùy chọn)
read -p "Đường dẫn model (Enter để chọn từ menu khi khởi động): " MODEL_PATH
if [ -n "$MODEL_PATH" ]; then
MODEL_ARG="--model $MODEL_PATH"
else
MODEL_ARG=""
fi
# Tạo file config model mặc định nếu chưa có và không dùng custom model
if [ -z "$MODEL_PATH" ] && [ ! -f "service_config.txt" ]; then
echo "1" > service_config.txt
chown $SUDO_USER:$SUDO_USER service_config.txt
echo "[✓] Đã tạo service_config.txt với model mặc định: 1"
fi
# Tạo file service từ template
echo
echo "[1/4] Tạo file systemd service..."
cat > /tmp/litert-lm.service << EOF
[Unit]
@@ -37,7 +54,7 @@ Type=simple
User=$SUDO_USER
WorkingDirectory=$CURRENT_DIR
Environment="PATH=/usr/bin:/usr/local/bin:$HOME/.local/bin"
ExecStart=$PYTHON_PATH $CURRENT_DIR/server.py
ExecStart=$PYTHON_PATH $CURRENT_DIR/server.py --port $SERVICE_PORT $MODEL_ARG
StandardInput=file:$CURRENT_DIR/service_config.txt
Restart=always
RestartSec=10
@@ -68,6 +85,14 @@ echo
echo "Service đã được cài đặt và khởi động."
echo "Server sẽ tự động chạy khi khởi động hệ thống."
echo
echo "Cấu hình:"
echo " - Port: $SERVICE_PORT"
if [ -n "$MODEL_PATH" ]; then
echo " - Model: $MODEL_PATH"
else
echo " - Model: Chọn từ menu (xem service_config.txt)"
fi
echo
echo "Các lệnh quản lý:"
echo " - Xem trạng thái: sudo systemctl status litert-lm"
echo " - Dừng service: sudo systemctl stop litert-lm"
@@ -76,7 +101,7 @@ echo " - Khởi động lại: sudo systemctl restart litert-lm"
echo " - Xem logs: sudo journalctl -u litert-lm -f"
echo " - Gỡ cài đặt: sudo bash uninstall_service.sh"
echo
echo "Server đang chạy tại: http://localhost:8000"
echo "Server đang chạy tại: http://localhost:$SERVICE_PORT"
echo
# Hiển thị trạng thái