npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

egg-pomelo

v0.0.9

Published

sex pomelo cli for egg

Downloads

3

Readme

egg-pomelo

NPM version NPM version

本插件用于为eggjs提供poemlo管理功能(pomelo-cli web版本)

使用例子

依赖说明

依赖的 egg 版本

egg-pomelo 版本 | egg 2.x

依赖的插件

安装

$ npm i egg-pomelo --save

开启插件

// config/plugin.js
exports.pomelo = {
  enable: true,
  package: 'egg-pomelo',
};

配置

// {app_root}/config/config.default.js
exports.pomelo = {
  client: {
    master: [{
      alias:'myTestMaster',
      host: '127.0.0.1',
      port: 3005,
      username: 'admin',
      password: 'admin',
    },
    {
      host: '192.168.0.12',
      port: 3005,
      username: 'admin',
      password: 'admin',
    },
    ],
  },
};

masterName规则

egg-pomelo 通过 masterName 来区分命令在哪一个 Pomelo Master 上运行。 master命令规则如下:

 let masterName = `${host}-${port}`;

上面配置项的 masterName 分别为:

  • 127.0.0.1-3005
  • 192.168.0.12-3005

详细配置

请到 config/config.default.js 查看详细配置项说明。

API

runAction

/** 运行命令
   *
   * @param {string} cmd 命令对象
   * @param {string} context 上下文(服务器名称)
   * @param {string} masterName 连接的那一台Master
   *
   * @return {{status:boolean},{data:object}} data 返回数据
   */
  async runAction(cmd, context = 'all', masterName = '');

例子:

// get servers
const ret = await this.app.pomelo.runAction('show servers', 'all','myTestMaster');

// get handler
const retHandler = await this.app.pomelo.runAction('show handler', 'chat-1','127.0.0.1-3005');

execStr

运行字符串脚本

/** 在指定的node 上执行脚本字符串
   *
   * @param {string} script 脚本内容
   * @param {string} context 执行上下文 serverId
   * @param {string} masterName 连接的那一台Master
   */
  async execStr(script, context, masterName = '');

例子:

await this.app.pomelo.execStr('var cpus = os.cpus();result = util.inspect(cpus,true,null);','chat-1','127.0.0.1-3005');

runMgrCmd

执行 egg-pomelo 管理命令

/** 运行 egg-pomelo 管理命令
   * run egg-pomelo manager command
   *
   * @param {string} cmd 命令对象
   *
   * @return {{status:boolean},{data:object}} data 返回数据
   */
  async runMgrCmd(cmd);

例子:

  const ret = await this.app.pomelo.runMgrCmd('getMasters');

支持的命令

  • getMasters, 获取当前拥有的master列表。

支持的pomelo-cli命令

Command list

consts.COMANDS_ALL = [
  [ 'command', '  description' ],
  [ '?', '  symbol for help' ],
  [ 'help', '  display the help' ],
  [ 'quit', '  quit pomelo-cli' ],
  [ 'kill', '  kill all servers' ],
  [ 'exec', '  exec script files' ],
  [ 'get', '  equal to app.get(key) ' ],
  [ 'set', '  equal to app.set(key, value)' ],
  [ 'add', '  add server to pomelo clusters' ],
  [ 'stop', '  stop server. Takes serverId as argument' ],
  [ 'show', '  show infos like : user, servers, connections, connectionInfo' ],
  [ 'use', '  use another server. Takes serverId as argument' ],
  [ 'enable', '  enable an admin console module or enable app settings' ],
  [ 'disable', '  disable an admin console module or disable app settings' ],
  [ 'addCron', '  add cron for server' ],
  [ 'removeCron', '  remove cron for server' ],
  [ 'blacklist', ' add blacklist for frontend server' ],
  [ 'run', ' run script in server' ],
  [ 'execStr', '  exec script String' ],
  [ 'systemInfo', ' show server systeminfo' ],
  [ 'nodeInfo', ' show node info' ],
  [ 'monitorLog', ' get Log' ],
];

更改记录

0.0.8

  1. update readme;
  2. 规范化 masterName 命名规则
  3. execStr add master support

0.0.7

  1. 增加多个Master连接功能;

0.0.5

  1. 使用 sex-pomelo-admin 1.0.7;
  2. 实现确保多个命令并行执行时,返回数据顺序正确;

0.0.4

  1. 使用 sex-pomelo-admin 1.0.6
  2. 支持 show connectionInfo 命令

0.0.3

  1. 使用 sex-pomelo-admin 1.0.5

0.0.2

  1. 增加语法提示功能
  2. 增加 monitorLog,systemInfo,nodeInfo 功能接口

0.0.1

  1. 实现基本功能

提问交流

请到 egg-pomelo issues 异步交流。

License

MIT