From e48b32abe033dee55e27de870d8e64b717916998 Mon Sep 17 00:00:00 2001 From: Cookie987 Date: Tue, 11 Mar 2025 16:40:53 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=9C=A8=E6=89=8B=E5=8A=A8=E9=83=A8?= =?UTF-8?q?=E7=BD=B2=E6=95=99=E7=A8=8B=E4=B8=AD=E5=A2=9E=E5=8A=A0=E4=BD=BF?= =?UTF-8?q?=E7=94=A8systemctl=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/manual_deploy_linux.md | 47 +++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/docs/manual_deploy_linux.md b/docs/manual_deploy_linux.md index 4711c81a9..0a68c6da9 100644 --- a/docs/manual_deploy_linux.md +++ b/docs/manual_deploy_linux.md @@ -110,6 +110,53 @@ python3 bot.py --- +### 7️⃣ **使用systemctl管理maimbot** + +使用以下命令添加服务文件: + +```bash +sudo nano /etc/systemd/system/maimbot.service +``` + +输入以下内容: + +```ini +[Unit] +Description=MaiMbot 麦麦 +After=network.target mongod.service + +[Service] +Type=simple +WorkingDirectory=/path/to/your/maimbot/ +ExecStart=/path/to/your/venv/python3 bot.py +Restart=always +RestartSec=10s + +[Install] +WantedBy=multi-user.target +``` + +输入以下命令重新加载 systemd: + +```bash +sudo systemctl daemon-reload +``` + +启动并设置开机自启: + +```bash +sudo systemctl start maimbot +sudo systemctl enable maimbot +``` + +输入以下命令查看日志: + +```bash +sudo journalctl -xeu maimbot +``` + +--- + ## **其他组件(可选)** - 直接运行 knowledge.py生成知识库 From 0586700467a5f91106d13bb0ad490b48726cc6d0 Mon Sep 17 00:00:00 2001 From: Cookie987 Date: Tue, 11 Mar 2025 16:49:52 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=8C=89=E7=85=A7Sourcery=E6=8F=90?= =?UTF-8?q?=E4=BE=9B=E7=9A=84=E5=BB=BA=E8=AE=AE=E4=BF=AE=E6=94=B9systemctl?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E6=8C=87=E5=8D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/manual_deploy_linux.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/docs/manual_deploy_linux.md b/docs/manual_deploy_linux.md index 0a68c6da9..1dbd74692 100644 --- a/docs/manual_deploy_linux.md +++ b/docs/manual_deploy_linux.md @@ -120,6 +120,9 @@ sudo nano /etc/systemd/system/maimbot.service 输入以下内容: +``:你的maimbot目录 +``:你的venv环境(就是上文创建环境后,执行的代码`source maimbot/bin/activate`中source后面的路径的绝对路径) + ```ini [Unit] Description=MaiMbot 麦麦 @@ -127,8 +130,8 @@ After=network.target mongod.service [Service] Type=simple -WorkingDirectory=/path/to/your/maimbot/ -ExecStart=/path/to/your/venv/python3 bot.py +WorkingDirectory= +ExecStart=/python3 bot.py Restart=always RestartSec=10s @@ -136,7 +139,7 @@ RestartSec=10s WantedBy=multi-user.target ``` -输入以下命令重新加载 systemd: +输入以下命令重新加载systemd: ```bash sudo systemctl daemon-reload From 20f009d0bb2c9f84d0b575be24ad874607833f90 Mon Sep 17 00:00:00 2001 From: Cookie987 Date: Tue, 11 Mar 2025 16:55:59 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dsystemctl=E5=BC=BA?= =?UTF-8?q?=E5=88=B6=E5=81=9C=E6=AD=A2maimbot=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/manual_deploy_linux.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/manual_deploy_linux.md b/docs/manual_deploy_linux.md index 1dbd74692..b19f3d6a7 100644 --- a/docs/manual_deploy_linux.md +++ b/docs/manual_deploy_linux.md @@ -132,6 +132,7 @@ After=network.target mongod.service Type=simple WorkingDirectory= ExecStart=/python3 bot.py +ExecStop=/bin/kill -2 $MAINPID Restart=always RestartSec=10s