This commit is contained in:
yumoqing 2025-05-22 07:16:47 +00:00
parent 943f4b4912
commit 497064c492

48
deploy.sh Executable file
View File

@ -0,0 +1,48 @@
#!/bin/bash
# 变量
#
# home
# user
# passwd
# modelpath
# modelname
# gpucnt
# port
#
# 开始要检查安装nvidia驱动
if [ "$#" -lt 3 ]; then
echo "用法: $0 <git_url1> <port> <python file under app folder>"
exit 1
fi
git_url=$1
pkgname=$(basename $git_url)
port=$2
usrname=$(id -un)
grpname=$(id -gn)
pkg_home=$(pwd)/pkgname
venvpath=$pkg_home/$pkgname.env
pip install git+$git_url
cd $pkg_home
python3 -m venv $envpath
source $envpath/bin/activate
pip install setuptools wheel
pip install git+https://git.kaiyuancloud.cn/yumoqing/apppublic
pip install git+https://git.kaiyuancloud.cn/yumoqing/sqlor
pip install git+https://git.kaiyuancloud.cn/yumoqing/ahserver
pip install -r requirements.txt
mkdir $pkg_home/script
cat <<EOF>$pkg_home/script/$pkgname.service
[Unit]
Wants=systemd-networkd.service
[Service]
User=$usrname
Group=$grpname
WorkingDirectory=$pkg_home
ExecStart=$envpath/bin/python app/$3
[Install]
WantedBy=multi-user.target
EOF
sudo ln -s $pkg_home/script/$pkgname.service /etc/systemd/system
sudo systemctl start $pkgname.service