# 基于midway 框架的通用项目

## QuickStart

<!-- add docs here for user -->

see [midway docs][midway] for more detail.

### Development

```bash
$ npm i
$ npm run dev
$ open http://localhost:port/
```

### Deploy

```bash
$ npm start
```

### npm scripts

- Use `npm run lint` to check code style.
- Use `npm test` to run unit test.


[midway]: https://midwayjs.org

### pm2配置

```bash
    {
        name: "xxx",
        script: "./bootstrap.js",
        instances: 1,
        exec_mode: "cluster",
        env: {
            "NODE_ENV": "xxx",
            "DB_NAME":"xxx",      //MYSQL 数据库名称
            "MYSQL_UNAME":"xxx",  //MYSQL 账号
            "MYSQL_PWD":"xxx",    //MYSQL 密码
            "MYSQL_HOST":"192.168.18.67",   //MYSQL 地址
            "MYSQL_PORT":3306,              //MYSQL 端口号
            "POOL_MAX":5,                   //MySQL 最大连接池数量
            "POOL_MIN":1,                   //mysql 最小链接池数量
            "REDIS_PORT":6379,              //redis 端口
            "REDIS_HOST":"192.168.18.67",   //redis 地址
            "REDIS_PWD":"xxx",              //redis 密码
            "REDIS_DB":1,                   //redis 数据库索引
            "APP_PORT":6379,                //项目端口
            "GLOBALPREFIX":"xxx",         //项目前缀
            "BULL_BOARD":"/xxx/uilist",   //项目任务队列的访问地址 如http://域名/BULL_BOARD配置项,
            "STATIC_PATH":"/static",        //动态的服务器静态文件访问前缀
            "APP_LIMITER":10,               //接口请求限流大小
            "WRITE_LOG":true,               //是否需要写入管理员操作日志
            "ACTION_LOG_WRITE":10,          //管理员操作日志写入时机,有10条就写入吧 只有当WRITE_LOG = true有效
        }
    }
```

### pm2 启动命令

```bash
    pm2 start pmrun.config.js --name xxx //根据上方的配置按需要启动
```

