项目作者: kelp404

项目描述 :
A real time admin panel of Bull(Redis-based queue) based on Express and WebSocket.
高级语言: JavaScript
项目地址: git://github.com/kelp404/bull-admin-panel.git
创建时间: 2020-03-18T06:38:29Z
项目社区:https://github.com/kelp404/bull-admin-panel

开源协议:MIT License

下载


bull-admin-panel

npm version
Actions Status

An admin panel of Bull based on WebSocket.

Installation

  1. npm install bull-admin-panel

Screenshots

Example

more details…

  1. const express = require('express');
  2. const http = require('http');
  3. const Bull = require('bull');
  4. const BullAdminPanel = require('bull-admin-panel');
  5. const app = express();
  6. const server = http.createServer(app);
  7. const queue = new Bull('queue-name', {
  8. redis: {
  9. host: 'localhost',
  10. port: 6379,
  11. db: 1
  12. }
  13. });
  14. app.use('/bull', new BullAdminPanel({
  15. basePath: '/bull',
  16. verifyClient: (info, callback) => {
  17. // Do authorization for WebSocket.
  18. // https://github.com/websockets/ws/blob/master/doc/ws.md#new-websocketserveroptions-callback
  19. callback(true);
  20. },
  21. queues: [queue],
  22. server: server
  23. }));
  24. // Launch server
  25. server.listen(8000, 'localhost', () => {
  26. const {address, port} = server.address();
  27. console.log(`Server listening at http://${address}:${port}`);
  28. });

Work with nginx

bull-admin-panel use WebSocket. You need config upgrade request.
NGINX as a WebSocket Proxy

  1. location / {
  2. proxy_pass http://127.0.0.1:8080;
  3. proxy_http_version 1.1;
  4. proxy_set_header Host $host;
  5. proxy_set_header Upgrade $http_upgrade;
  6. proxy_set_header Connection $http_connection;
  7. }

Options

basePath

Type: string
Required: required
The bull admin panel base path. We pass to frontend app.

socketValidationPath

Type: string
Required: optional
The default value is copy from basePath. The websocket just accepts to connect via this path.
If your site has rewrite path settings. You can use this option.

verifyClient

Type: function(info: object, callback: function)
Required: required
For websocket authorization.
More information:

queues

Type: Array<Bull>
Required: required
Bull instances.

  1. const Bull = require('bull');
  2. const queues = [
  3. new Bull('queue-a', 'redis://localhost:6379/0'),
  4. new Bull('queue-b', 'redis://localhost:6379/0')
  5. ];

server

Type: http.Server
Required: required
The node.js http.Server instance.

Develop

Fork this repository then clone it.

  1. Install node modules.
    npm install

  2. Start the develop server.
    npm start