Skip to content

Commit

Permalink
docs: add update guide
Browse files Browse the repository at this point in the history
Signed-off-by: ZTL-UwU <zhangtianli2006@163.com>
  • Loading branch information
ZTL-UwU committed Sep 5, 2024
1 parent 946f586 commit a3f8e3d
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,25 @@ icon: ph:tree-view-duotone

使用 [Git](https://git-scm.com/) 版本控制系统(VCS)克隆项目仓库到本地。运行命令:

```shell
```bash
git clone https://github.com/SMS-COSMO/SMS-Tree
```

进入项目文件目录:

```bash
cd SMS-Tree
```

初始化 Git 子模块(pdfjs):

```bash
git submodule update --init --recursive
```

为了安装项目的依赖,请在仓库根目录运行命令:

```shell
```bash
pnpm i
```

Expand All @@ -45,7 +57,7 @@ pnpm i
::alert
DrizzleORM 支持以可视化形式查看和编辑数据库内容。运行命令:

```shell
```bash
pnpm db:studio
```

Expand All @@ -58,7 +70,7 @@ pnpm db:studio

完成上述准备工作后,就可以启动本地服务器来进行测试了。运行命令:

```shell
```bash
pnpm dev
```

Expand Down
130 changes: 92 additions & 38 deletions docs/developer/content/2.deploying/1.local.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,39 +11,6 @@ icon: ph:computer-tower-duotone

整个应用程序依赖三个部分,分别是由 Node.js 运行的 Nuxt 部分,数据库部分,和文件存储部分。Nuxt 部分由 pm2 工具启动,并且在后台运行;数据库和文件存储部分均使用 systemd 运行。

## 相关文档

::card-group{class="mt-6"}
::card
---
title: PM2
to: https://pm2.keymetrics.io/docs/usage/quick-start/
target: _blank
---
::
::card
---
title: postgresql
to: https://www.postgresql.org/
target: _blank
---
::
::card
---
title: MinIO
to: https://min.io/docs/minio/kubernetes/upstream/
target: _blank
---
::
::card
---
title: Nuxt(部署相关)
to: https://nuxt.com/docs/getting-started/deployment
target: _blank
---
::
::

## 安装和配置数据库

::steps{level=4}
Expand Down Expand Up @@ -254,10 +221,26 @@ sudo journalctl -u minio
```bash
git clone https://github.com/SMS-COSMO/SMS-Tree.git
cd SMS-Tree
git submodule update --init --recursive
pnpm install --registry=https://registry.npmmirror.com
pnpm build
```

#### 配置环境变量

::alert{to="/introduction/getting-started/env"}
点击这里查看 `.env` 的配置方法
::

#### 初始化数据库

第一次创建数据库时,需要对数据库进行初始化。

```bash
pnpm db:push
pnpm db:createAdmin # 创建管理员用户
```

#### 运行以下命令安装 pm2

```bash
Expand All @@ -266,11 +249,7 @@ pnpm install pm2 -g

#### 配置 pm2

`SMS-Tree/`**父级**目录下新建文件 `ecosystem.config.js`,其中 `env: {}` 的内容与 `.env` 相同:

::alert{to="/introduction/getting-started/env"}
点击这里查看 `.env` 的配置方法
::
`SMS-Tree/`**父级**目录下新建文件 `ecosystem.config.js`,其中 `env: {}` 的内容与 `.env` 相同。只需把 `XXX=XXX` 改为 `XXX: XXX` 即可:

```js [内容示例]
module.exports = {
Expand All @@ -291,10 +270,17 @@ module.exports = {
ENC_KID: '',
SIGN_KID: '',
SERVER_URL: '',
TOKEN_EXPIRATION_TIME: '',
SEIUE_LOGIN: '',
SEIUE_API_URL: '',
SEIUE_OPEN_API_URL: '',
SEIUE_CHALK_UR: '',
SEIUE_PASSPORT_URL: '',
S3_ACCESS_KEY_ID: '',
S3_SECRET_ACCESS_KEY: '',
BUCKET_NAME: '',
S3_SERVER_URL: '',
CHATGPT_DETECTOR_API: '',
},
},
],
Expand All @@ -303,6 +289,8 @@ module.exports = {

#### 启动 pm2

`SMS-Tree/`**父级**目录下运行:

```bash
pm2 start ecosystem.config.js
```
Expand Down Expand Up @@ -343,3 +331,69 @@ pm2 delete <id>
当环境变量更改或重新构建后,需要先删除所有相应的 pm2 进程,再重新启动 pm2。
::
::

## 更新 SMS-Tree

当 SMS-Tree 的 GitHub 仓库产生更新时,需要在服务器上更新代码版本。

::steps{level=4}
#### 停止 PM2 进程

```bash
pm2 delete all
```

#### 拉取新版代码

```bash
cd SMS-Tree
git pull
```

#### 更新依赖 & 构建

```bash
pnpm install --registry=https://registry.npmmirror.com
pnpm build
```

#### 重启 PM2 进程

```bash
cd ..
pm2 start ecosystem.config.js
```
::

## 相关文档

::card-group{class="mt-6"}
::card
---
title: PM2
to: https://pm2.keymetrics.io/docs/usage/quick-start/
target: _blank
---
::
::card
---
title: postgresql
to: https://www.postgresql.org/
target: _blank
---
::
::card
---
title: MinIO
to: https://min.io/docs/minio/kubernetes/upstream/
target: _blank
---
::
::card
---
title: Nuxt(部署相关)
to: https://nuxt.com/docs/getting-started/deployment
target: _blank
---
::
::
5 changes: 0 additions & 5 deletions docs/developer/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,4 @@
export default defineNuxtConfig({
devtools: { enabled: true },
extends: ['shadcn-docs-nuxt'],
content: {
highlight: {
langs: ['sql'],
},
},
});
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "sms-tree",
"type": "module",
"private": true,
"packageManager": "pnpm@9.9.0+sha512.60c18acd138bff695d339be6ad13f7e936eea6745660d4cc4a776d5247c540d0edee1a563695c183a66eb917ef88f2b4feb1fc25f32a7adcadc7aaf3438e99c1",
"scripts": {
"build": "nuxt build",
"dev": "nuxt dev",
Expand Down

0 comments on commit a3f8e3d

Please sign in to comment.