Browse Source

添加pm2文件和本机启动配置文件,本机启动指令

lrf 10 months ago
parent
commit
c0c3e5c9e2
3 changed files with 103 additions and 0 deletions
  1. 20 0
      ecosystem.config.js
  2. 1 0
      package.json
  3. 82 0
      src/config/config.self.ts

+ 20 - 0
ecosystem.config.js

@@ -0,0 +1,20 @@
+'use strict';
+// 开发服务设置
+const app = 'service';
+module.exports = {
+  apps: [
+    {
+      name: app, // 应用名称
+      script: './bootstrap.js', // 实际启动脚本
+      out: `./logs/${app}.log`,
+      error: `./logs/${app}.err`,
+      watch: [
+        // 监控变化的目录,一旦变化,自动重启
+        'dist',
+      ],
+      env: {
+        NODE_ENV: 'production', // 环境参数,当前指定为生产环境
+      },
+    },
+  ],
+};

+ 1 - 0
package.json

@@ -40,6 +40,7 @@
   "scripts": {
     "start": "NODE_ENV=production node ./bootstrap.js",
     "dev": "cross-env NODE_ENV=local mwtsc --watch --run @midwayjs/mock/app.js",
+    "self": "cross-env NODE_ENV=self mwtsc --watch --run @midwayjs/mock/app.js",
     "test": "cross-env NODE_ENV=unittest jest",
     "cov": "jest --coverage",
     "lint": "mwts check",

+ 82 - 0
src/config/config.self.ts

@@ -0,0 +1,82 @@
+import { MidwayConfig } from '@midwayjs/core';
+/**数据库ip */
+const ip = 'localhost';
+/**数据库名 */
+const dbName = 'cxyy';
+/**日志数据库名 */
+const logsDB = 'cxyy_logs';
+/**数据库用户名 */
+const dbUsername = 'system';
+/**数据库密码 */
+const dbPwd = '1234qwer!@#$';
+/**redis ip */
+const redisHost = 'localhost';
+/**redis 密码 */
+const redisPwd = '1234qwer!@#$';
+/**redis 使用第几个数据库 */
+const redisDB = 0;
+/**redis 记录登录的key */
+const loginSign = 'cxyy';
+export default {
+  // use for cookie sign key, should change to your own and keep security
+  keys: '1697684406848_4978',
+  loginSign,
+  // 请求记录在redis留存时间,超过时间.数据变化将不会记录.以秒为单位--5分钟
+  requestTimeLimit: 300,
+  jwt: {
+    secret: 'Ziyouyanfa!@#',
+    expiresIn: 3600, // 3600
+  },
+  koa: {
+    port: 9700,
+    globalPrefix: '/cxyy/api',
+    queryParseMode: 'extended',
+  },
+  swagger: {
+    swaggerPath: '/doc/api',
+  },
+  elasticsearch: {
+    node: 'http://192.168.1.197:9200',
+    auth: {
+      username: 'elastic',
+      password: 'NAjqFz_7tS2DkdpU7p*x',
+    },
+  },
+  typeorm: {
+    dataSource: {
+      default: {
+        database: dbName,
+        username: dbUsername,
+        password: dbPwd,
+        host: ip,
+        port: 54321,
+        entities: ['./entity'],
+        type: 'postgres',
+        synchronize: false, // 如果第一次使用,不存在表,有同步的需求可以写 true,注意会丢数据
+        logging: true,
+      },
+      logs: {
+        database: logsDB,
+        username: dbUsername,
+        password: dbPwd,
+        host: ip,
+        port: 54321,
+        entities: ['./entityLogs'],
+        type: 'postgres',
+        synchronize: false, // 如果第一次使用,不存在表,有同步的需求可以写 true,注意会丢数据
+        logging: true,
+      },
+    },
+  },
+  redis: {
+    client: {
+      port: 6379, // Redis port
+      host: redisHost, // Redis host
+      password: redisPwd,
+      db: redisDB,
+    },
+  },
+  upload: {
+    whitelist: null,
+  },
+} as MidwayConfig;