Skip to content

Commit

Permalink
feat: application supervisor (nocobase#2353)
Browse files Browse the repository at this point in the history
* chore: skip sync localization-management plugin enable status

* chore: unSyncPlugins array

* chore: remove install at dev

* chore: gateway and supervisor

* chore: install command

* chore: remove app manager

* chore: share plugin

* chore: wsserver

* chore: websocket server

* chore: websocket connection with app status

* feat: socket server at gateway

* chore: loading message

* chore: ready status

* chore: handle app error

* feat: restart app at supervisor

* feat: health check endpoint

* chore: test

* chore: test

* chore: test

* chore: test

* chore: build

* chore: test

* chore: build

* chore: application ready status

* chore: error message

* chore: handle application error

* chore: handle error in load

* chore: report error in websocket

* chore: ws error

* chore: ws error

* chore: typo

* chore: switch app ready status at install

* chore: test

* chore: test

* chore: test

* chore: test

* feat: add WebSocket client

* chore: start gateway

* chore: start command in application

* chore: code

* chore: pm command

* chore: run start after load sub app

* feat: application fsm

* refactor: server life cycle (nocobase#2402)

* refactor: server life cycle

* fix: test error

* fix: test error

* fix: test error

* fix: app.start

* fix: cronjob stop

* fix: db.sync before upgrade

* fix: pm.get

* fix: test error

* fix: test error

* fix: test error

* test: add test cases

* fix: remove PluginType

* chore: start application after install

* chore: fsm

* chore: working status

* chore: working command

* chore: remove swith app ready status

* chore: switch status after working done

* chore: ws status

* chore: gateway error

* chore: test

* chore: stopping status

* chore: test

* chore: test

* feat: app proxy

* chore: application destory

* chore: application message changed with status

* chore: test

* chore: test timeout

* test: remove listener add by plugin

* test: remove listener add by plugin

* chore: test

* feat: app maintaining

* fix: add AppMaintainingDialog

* feat: off

* test: gateway http response

* test: gateway with errors

* chore: unkown error

* chore: websocket message

* chore: ws message

* chore: code

* chore: error format

* chore: delay app load

* feat: improve code

* chore: application initializing status

* chore: supervisor with app status

* chore: command status response

* chore: test

* chore: ws message

* chore: test

* fix: command running message

* feat: restart

* chore: code

* chore: status transition

* chore: test

* fix: improve code

* fix: error

* fix: restart

* fix: command

* chore: reset client app tag when app selector changed

* chore: error report

* fix: application status

* fix: build

* chore: disable help command dispatch

* chore: test

* test: multi apps test

* fix: improve code

* fix: test

* fix: test

* fix: multi apps single running

* fix: improve code

* fix: app status

* chore: move plugin static file to gateway

* feat: static file handler

* chore: test

* chore: enable plugins in share collection

* chore: gateway serve upload files

* fix: improve client

* chore: ws nginx config

* fix: gateway with naonoid

* fix: db sync

* fix: loading

* fix: ping

* fix: locale load

* fix: yarn start --quickstart

* fix: add debug log

* chore: application started event

* chore: running working message payload

* chore: nginx log

* chore: nginxconf

* chore: working message log

* feat: logs

* feat: compression

* fix: remove koa-send and koa-static

* fix: remove -e

* fix: remove nginx

* fix: remove -e

* fix: __appName

* chore: delay install sub application

* chore: sync plugin status

* fix: boot sub app

* fix: main app reload

* fix: test

* fix: app status

* test: field.bind block event loop

* feat: newrelic

* feat: debug log

* chore: upgrade

* fix(file-manager): test error

* fix: default app selector

* fix: reload after maintained

* chore: boot sub app

* chore: application destroy command

* chore: destroy command

* chore: clean code

* chore: package.json

* chore: maintaining message

* chore: test

* fix: collection.sync

* feat: add test cases

* chore: application

* fix: test error

* feat: improve codes and add test cases

* fix: test error

* fix: pm enable and disable

* fix: pm.disable

* feat: update docs

* chore: update dockerfile

---------

Co-authored-by: chenos <[email protected]>
  • Loading branch information
chareice and chenos authored Aug 24, 2023
1 parent 0f9d946 commit 39ee4b8
Show file tree
Hide file tree
Showing 149 changed files with 5,701 additions and 1,963 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ INIT_ROOT_USERNAME=nocobase
DEFAULT_STORAGE_TYPE=local

# LOCAL STORAGE
LOCAL_STORAGE_BASE_URL=
LOCAL_STORAGE_BASE_URL=/storage/uploads
LOCAL_STORAGE_DEST=storage/uploads

# ALI OSS STORAGE
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/nocobase-test-backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
DB_DIALECT: sqlite
DB_STORAGE: /tmp/db.sqlite
DB_UNDERSCORED: ${{ matrix.underscored }}
timeout-minutes: 35
timeout-minutes: 40

postgres-test:
strategy:
Expand Down Expand Up @@ -92,7 +92,7 @@ jobs:
DB_UNDERSCORED: ${{ matrix.underscored }}
DB_SCHEMA: ${{ matrix.schema }}
COLLECTION_MANAGER_SCHEMA: ${{ matrix.collection_schema }}
timeout-minutes: 35
timeout-minutes: 40

mysql-test:
strategy:
Expand Down Expand Up @@ -128,4 +128,4 @@ jobs:
DB_PASSWORD: password
DB_DATABASE: nocobase
DB_UNDERSCORED: ${{ matrix.underscored }}
timeout-minutes: 35
timeout-minutes: 40
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ RUN cd /app \
FROM node:16.20-bullseye-slim
RUN apt-get update && apt-get install -y nginx
RUN rm -rf /etc/nginx/sites-enabled/default
COPY ./docker/nocobase/nocobase.conf /etc/nginx/sites-enabled/nocobase.conf
COPY --from=builder /app/nocobase.tar.gz /app/nocobase.tar.gz
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ NocoBase is in early stage of development and is subject to frequent changes, pl

## Recent major updates

- [v0.13: New application status flow - 2023/08/24](https://docs.nocobase.com/welcome/release/v13-changelog)
- [v0.12: New plugin build tool - 2023/08/01](https://docs.nocobase.com/welcome/release/v12-changelog)
- [v0.11: New client application, plugin and router - 2023/07/08](http://docs.nocobase.com/welcome/release/v11-changelog)
- [v0.10: Update instructions - 2023/06/23](http://docs.nocobase.com/welcome/release/v10-changelog)
Expand Down
2 changes: 2 additions & 0 deletions README.tr-TR.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ NocoBase v0.10 has been released, see [v0.10: update instructions](http://docs.n

## Recent major updates

- [v0.13: New application status flow - 2023/08/24](https://docs.nocobase.com/welcome/release/v13-changelog)
- [v0.12: New plugin build tool - 2023/08/01](https://docs.nocobase.com/welcome/release/v12-changelog)
- [v0.11: New client application, plugin and router - 2023/07/08](http://docs.nocobase.com/welcome/release/v11-changelog)
- [v0.10: Update instructions - 2023/06/23](http://docs.nocobase.com/welcome/release/v10-changelog)

Expand Down
1 change: 1 addition & 0 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ NocoBase 正处在早期开发阶段,可能变动频繁,请谨慎用于生

## 最近重要更新

- [v0.13: 全新的应用状态流转 - 2023/08/24](https://docs-cn.nocobase.com/welcome/release/v13-changelog)
- [v0.12: 全新的插件构建工具 - 2023/08/01](https://docs-cn.nocobase.com/welcome/release/v12-changelog)
- [v0.11: 全新的客户端 Application、Plugin 和 Router - 2023/07/08](https://docs-cn.nocobase.com/welcome/release/v11-changelog)
- [v0.10: Update instructions - 2023/06/23](https://docs-cn.nocobase.com/welcome/release/v10-changelog)
Expand Down
16 changes: 16 additions & 0 deletions docker/nocobase-full/nocobase.conf
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
log_format apm '"$time_local" client=$remote_addr '
'method=$request_method request="$request" '
'request_length=$request_length '
'status=$status bytes_sent=$bytes_sent '
'body_bytes_sent=$body_bytes_sent '
'referer=$http_referer '
'user_agent="$http_user_agent" '
'upstream_addr=$upstream_addr '
'upstream_status=$upstream_status '
'request_time=$request_time '
'upstream_response_time=$upstream_response_time '
'upstream_connect_time=$upstream_connect_time '
'upstream_header_time=$upstream_header_time';

server {
listen 80;
server_name _;
root /app/nocobase/packages/app/client/dist;
index index.html;
client_max_body_size 20M;

access_log /var/log/nginx/nocobase.log apm;

location /storage/uploads/ {
alias /app/nocobase/storage/uploads/;
autoindex off;
Expand Down
23 changes: 23 additions & 0 deletions docker/nocobase/nocobase.conf
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
log_format apm '"$time_local" client=$remote_addr '
'method=$request_method request="$request" '
'request_length=$request_length '
'status=$status bytes_sent=$bytes_sent '
'body_bytes_sent=$body_bytes_sent '
'referer=$http_referer '
'user_agent="$http_user_agent" '
'upstream_addr=$upstream_addr '
'upstream_status=$upstream_status '
'request_time=$request_time '
'upstream_response_time=$upstream_response_time '
'upstream_connect_time=$upstream_connect_time '
'upstream_header_time=$upstream_header_time';

server {
listen 80;
server_name _;
root /app/nocobase/node_modules/@nocobase/app/dist/client;
index index.html;
client_max_body_size 20M;
access_log /var/log/nginx/nocobase.log apm;

gzip on;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
Expand Down Expand Up @@ -50,4 +65,12 @@ server {
proxy_read_timeout 600;
send_timeout 600;
}

location /ws {
proxy_pass http://127.0.0.1:13000/ws;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $host;
}
}
1 change: 1 addition & 0 deletions docs/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ const sidebar = {
},
// '/welcome/release/index',
// '/welcome/release/v08-changelog',
'/welcome/release/v13-changelog',
'/welcome/release/v12-changelog',
'/welcome/release/v11-changelog',
'/welcome/release/v10-changelog',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
# Upgrading for `create-nocobase-app`

## Minor version upgrade
<Alert>

Just execute the `nocobase upgrade` upgrade command
After v0.12, apps installed via `create-nocobase-app` no longer have a `packages/app` directory, and code customized in `packages/app` needs to be moved to the custom plugin.

</Alert>

## Upgrading

After v0.12, upgrading the application can be done by running the `yarn nocobase upgrade` command.

```bash
# Switch to the corresponding directory
Expand All @@ -13,63 +19,4 @@ yarn nocobase upgrade
yarn dev
```

## Major upgrade

You can also use this upgrade method if a minor upgrade fails.

### 1. Create a new NocoBase project

```bash
## SQLite
yarn create nocobase-app my-nocobase-app -d sqlite
# MySQL
yarn create nocobase-app my-nocobase-app -d mysql
# PostgreSQL
yarn create nocobase-app my-nocobase-app -d postgres
```

### 2. Switching directories

```bash
cd my-nocobase-app
```

### 3. Install dependencies

📢 This next step may take more than ten minutes due to network environment, system configuration and other factors.

```bash
yarn install
```

### 4. Modify the .env configuration

Refer to the old version of .env to modify, the database information needs to be configured correctly. The SQLite database also needs to be copied to the `. /storage/db/` directory.

### 5. Old code migration (not required)

Business code refer to the new version of plug-in development tutorial and API reference for modification.

### 6. Execute the upgrade command

The code is already the latest version, so you need to skip the code update `--skip-code-update` when upgrading.

```bash
yarn nocobase upgrade --skip-code-update
```

### 7. Start NocoBase

development environment

```bash
yarn dev
```

Production environment

```bash
yarn start # Not supported on win platforms yet
```

Note: For production environment, if the code has been modified, you need to execute ``yarn build`` and restart NocoBase.
If there are problems with upgrading, you can also [recreate new app](/welcome/getting-started/installation/create-nocobase-app) and refer to the old version of .env to change the environment variables. The database information needs to be configured correctly. When using a SQLite database, you need to copy the database files to the `./storage/db/` directory. Finally, run `yarn nocobase upgrade` to upgrade.
12 changes: 4 additions & 8 deletions docs/en-US/welcome/getting-started/upgrading/git-clone.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,12 @@ cd my-nocobase-app
git pull
```

## 3. 删除旧依赖文件(非必须)

v0.10 进行了依赖的重大升级,如果 v0.9 升级 v0.10,需要删掉以下目录之后再升级
## 3. Delete cache and dependencies (optional)

```bash
# Remove .umi cache
yarn rimraf -rf "./**/{.umi,.umi-production}"
# Delete compiled files
yarn rimraf -rf "./packages/*/*/{lib,esm,es,dist,node_modules}"
# Remove dependencies
# delete nocobase cache
yarn nocobase clean
# delete dependencies
yarn rimraf -rf node_modules
```

Expand Down
19 changes: 19 additions & 0 deletions docs/en-US/welcome/release/v13-changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# v0.13: New application status flow

## New Features

### Application status flow

<img src="https://nocobase.oss-cn-beijing.aliyuncs.com/57c8e420be0c9c27392d793d5073c060.png" />

### Demo video

<video controls width="100%">
<source src="https://nocobase.oss-cn-beijing.aliyuncs.com/6430cb4ca6310724a7c25a256bce995f.mp4" type="video/mp4" />
</video>

## Upgrading

- [Upgrading for Docker compose](/welcome/getting-started/upgrading/docker-compose)
- [Upgrading for create-nocobase-app](/welcome/getting-started/upgrading/create-nocobase-app)
- [Upgrading for Git source code](/welcome/getting-started/upgrading/git-clone)
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# `create-nocobase-app` 安装的升级

<Alert>
通过 create-nocobase-app 安装的应用不再有 packages/app 目录了,在 packages/app 里自定义的代码,需要移至自定义插件中。
v0.12 之后的版本,通过 create-nocobase-app 安装的应用不再有 packages/app 目录了,在 packages/app 里自定义的代码,需要移至自定义插件中。
</Alert>

## 小版本升级
## 版本升级

执行 `nocobase upgrade` 升级命令即可
v0.12 之后的版本,应用的升级直接执行 `yarn nocobase upgrade` 升级命令即可

```bash
# 切换到对应的目录
Expand All @@ -17,63 +17,4 @@ yarn nocobase upgrade
yarn dev
```

## 大版本升级

如果小版本升级失效,也可以采用此升级办法。

### 1. 创建新的 NocoBase 项目

```bash
# SQLite
yarn create nocobase-app my-nocobase-app -d sqlite
# MySQL
yarn create nocobase-app my-nocobase-app -d mysql
# PostgreSQL
yarn create nocobase-app my-nocobase-app -d postgres
```

### 2. 切换目录

```bash
cd my-nocobase-app
```

### 3. 安装依赖

📢 由于网络环境、系统配置等因素影响,接下来这一步骤可能需要十几分钟时间。

```bash
yarn install
```

### 4. 修改 .env 配置

参考旧版本的 .env 修改,数据库信息需要配置正确。SQLite 数据库也需要将数据库文件复制到 `./storage/db/` 目录。

### 5. 旧代码迁移(非必须)

业务代码参考新版插件开发教程和 API 参考进行修改。

### 6. 执行升级命令

代码已经是最新版了,所以 upgrade 时需要跳过代码更新 `--skip-code-update`

```bash
yarn nocobase upgrade --skip-code-update
```

### 7. 启动 NocoBase

开发环境

```bash
yarn dev
```

生产环境

```bash
yarn start
```

注:生产环境,如果代码有修改,需要执行 `yarn build`,再重新启动 NocoBase。
如果升级存在问题,也可以[重新创建新应用](/welcome/getting-started/installation/create-nocobase-app),并参考旧版本的 .env 修改环境变量。数据库信息需要配置正确,使用 SQLite 数据库时,需要将数据库文件复制到 `./storage/db/` 目录。最后再执行 `yarn nocobase upgrade` 进行升级。
12 changes: 5 additions & 7 deletions docs/zh-CN/welcome/getting-started/upgrading/git-clone.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,14 @@ cd my-nocobase-app
git pull
```

## 3. 删除旧依赖文件(非必须)
## 3. 删除缓存和旧依赖(非必须)

v0.10 进行了依赖的重大升级,如果 v0.9 升级 v0.10,需要删掉以下目录之后再升级
如果正常的升级流程失败,可以尝试清空缓存和依赖之后重新下载

```bash
# 删除 .umi 相关缓存
yarn rimraf -rf "./**/{.umi,.umi-production}"
# 删除编译文件
yarn rimraf -rf "./packages/*/*/{lib,esm,es,dist,node_modules}"
# 删除全部依赖
# 删除 nocobase 缓存
yarn nocobase clean
# 删除依赖
yarn rimraf -rf node_modules
```

Expand Down
19 changes: 19 additions & 0 deletions docs/zh-CN/welcome/release/v13-changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# v0.13:全新的应用状态流转

## 新特性

### 应用状态流转

<img src="https://nocobase.oss-cn-beijing.aliyuncs.com/57c8e420be0c9c27392d793d5073c060.png" />

### 演示视频

<video controls width="100%">
<source src="https://nocobase.oss-cn-beijing.aliyuncs.com/6430cb4ca6310724a7c25a256bce995f.mp4" type="video/mp4" />
</video>

## 应用升级

- [Docker 安装的升级](/welcome/getting-started/upgrading/docker-compose)
- [create-nocobase-app 安装的升级](/welcome/getting-started/upgrading/create-nocobase-app)
- [Git 源码安装的升级](/welcome/getting-started/upgrading/git-clone)
3 changes: 2 additions & 1 deletion examples/app/__tests__/app.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ import { MockServer, mockServer } from '@nocobase/test';
describe('app test', () => {
let app: MockServer;

beforeEach(() => {
beforeEach(async () => {
app = mockServer();
await app.start();
});

test('test1', async () => {
Expand Down
Loading

0 comments on commit 39ee4b8

Please sign in to comment.