登录
原创

Kong 的管理后台 Konga

专栏打造 API 聚合平台
发布于 2021-03-18 阅读 2850
  • 后端
原创

konga.png

简介

Konga 是 Kong 的一个开源的管理后台。

官方网站:https://github.com/pantsel/konga

安装

环境要求

确保已安装 npm 、node.js、bower。

下载 Konga 源码

git clone https://github.com/pantsel/konga.git

安装依赖

npm run postinstall && npm i

生成配置文件

cp .env.example .env

参考配置文件

.env 文件内容参考:

PORT=1337
NODE_ENV=production
KONGA_HOOK_TIMEOUT=120000
DB_ADAPTER=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_USER=konga
DB_DATABASE=konga
DB_PASSWORD=konga
KONGA_LOG_LEVEL=warn
TOKEN_SECRET=some_secret_token

以上配置文件使用了本机的 MySQL 数据库。

执行数据库迁移

node ./bin/konga.js  prepare --adapter mysql --uri mysql://localhost:5432/konga

数据库中会生成 Konga 的相关表:

WX202103181151362x.png

启动 Konga

npm run production

输出:

> kongadmin@0.14.9 production /www/wwwroot/konga
> node --harmony app.js --prod

(node:4108059) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
(node:4108059) [DEP0095] DeprecationWarning: timers.enroll() is deprecated. Please use setTimeout instead.
(node:4108059) [DEP0126] DeprecationWarning: timers.active() is deprecated. Please use timeout.refresh() instead.
(node:4108059) [DEP0096] DeprecationWarning: timers.unenroll() is deprecated. Please use clearTimeout instead.

保持 Konga 在后台运行

在生产环境中,执行:

pm2 start app.js --name konga

输出:

│ id  │ name   │ namespace   │ version │ mode    │ pid      │ uptime │ ↺    │ status    │ cpu      │ mem      │ user     │ watching │
├─────┼────────┼─────────────┼─────────┼─────────┼──────────┼────────┼──────┼───────────┼──────────┼──────────┼──────────┼──────────┤
│ 1   │ app    │ default     │ 0.14.9  │ fork    │ 4126729  │ 76s    │ 0    │ online    │ 0%       │ 94.1mb   │ www      │ disabled │
└─────┴────────┴─────────────┴─────────┴─────────┴──────────┴────────┴──────┴───────────┴──────────┴──────────┴──────────┴──────────┘

评论区

admin
14粉丝

打江山易,守江山难,负重前行,持续创新。

1

0

0

举报