Gathering detailed insights and metrics for @sex-pomelo/sex-pomelo-admin
Gathering detailed insights and metrics for @sex-pomelo/sex-pomelo-admin
Gathering detailed insights and metrics for @sex-pomelo/sex-pomelo-admin
Gathering detailed insights and metrics for @sex-pomelo/sex-pomelo-admin
npm install @sex-pomelo/sex-pomelo-admin
Typescript
Module System
Node Version
NPM Version
JavaScript (99.65%)
Makefile (0.35%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
187 Commits
2 Forks
1 Watchers
7 Branches
1 Contributors
Updated on Jul 09, 2025
Latest Version
1.0.10
Package Id
@sex-pomelo/sex-pomelo-admin@1.0.10
Unpacked Size
125.98 kB
Size
25.72 kB
File Count
32
NPM Version
10.9.2
Node Version
22.14.0
Published on
Jul 09, 2025
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
sex-pomelo-admin
is an admin console library for pomelo. It provides the a series of utilities to monitor the pomelo
server clusters.
npm install @sex-pomelo/sex-pomelo-admin
There are three process roles in pomelo-admin
: master, monitor and client.
master - the master server process, collects and maintains all the client and monitor status and exports the cluster status for the clients.
monitor - monitor proxy, in every server process which needs to be monitored. It should be started during the process starts and registers itself to the master server and reports the monitored process status to the master.
client - pomelo-admin
client process that fetches the status from master server, such as sex-pomelo-web and pomelo-cli.
There are two message types of the communication between processes.
request - bidirectional message that cooperated with response.
notify - unidirectional message.
Main service of pomelo-admin
that runs in both master and monitor processes. It maintains the master agent or monitor agent for the process, loads the registed modules and provides the messages routing service for the messages from other processes.
pomelo-admin
agent that runs on the master process to provide the basic network communication and protocol encoding and decoding.
pomelo-admin
agent that runs on the monitor process to provide the basic network communication and protocol encoding and decoding.
Module is the place to implement the monitor logic, such as process status collecting. Developer can register modules in pomelo-admin
to customize all kinds of system monitors.
There are three optional callback functions in each module.
function masterHandler(agent, msg, cb) - callback in master process to process a message from monitor process or a timer event in master process.
function monitorHandler(agent, msg, cb) - callback in monitor process to process a message from master process or a timer event in monitor process.
function clientHandler(agent, msg, cb) - callback in master process to process a message from client.
The relations of the components is as below:
1var admin = require("pomelo-admin");
Create a consoleService instance in master process.
1var masterConsole = admin.createMasterConsole({ 2 port: masterPort 3});
Register an admin module.
1masterConsole.register(moduleId, module);
Start masterConsole.
1masterConsole.start(function(err) { 2 // start servers 3});
Create a consoleService instance in monitor process.
1var monitorConsole = admin.createMonitorConsole({ 2 id: serverId, 3 type: serverType, 4 host: masterInfo.host, 5 port: masterInfo.port, 6 info: serverInfo 7});
Developers can customize modules to collect and export additional status as they need.
1var Module = function(app, opts) { 2 opts = opts || {}; 3 this.type = opts.type || 'pull'; // pull or push 4 this.interval = opts.interval || 5; // pull or push interval 5}; 6 7Module.moduleId = 'helloPomelo'; 8 9module.exports = Module; 10 11Module.prototype.monitorHandler = function(agent, msg) { 12 var word = agent.id + ' hello pomelo'; 13 // notify admin messages to master 14 agent.notify(Module.moduleId, {serverId: agent.id, body: word}); 15}; 16 17Module.prototype.masterHandler = function(agent, msg) { 18 // if no message, then notify all monitors to fetch datas 19 if(!msg) { 20 agent.notifyAll(Module.moduleId); 21 return; 22 } 23 // collect data from monitor 24 var data = agent.get(Module.moduleId); 25 if(!data) { 26 data = {}; 27 agent.set(Module.moduleId, data); 28 } 29 30 data[msg.serverId] = msg; 31}; 32 33Module.prototype.clientHandler = function(agent, msg, cb) { 34 // deal with client request,directly return data cached in master 35 cb(null, agent.get(Module.moduleId) || {}); 36};
you must register your customized modules to pomelo to make it work.
write in app.js which is in your project's root directory
1app.configure('production|development', function() { 2 app.registerAdmin('helloPomelo',new helloPomelo()); 3});
pomelo-admin defines user level for admin client to login master server in this schema
1{ 2 "id": "user-1", 3 "username": "admin", 4 "password": "admin", 5 "level": 1 6}
level defines the user admin level
level 1 means the user has the admin permission, this user can do anything
other level user will have limited permission
currently add, stop, kill will require level 1 permission
note: by default you should provide adminUser.json file under the config dir
adminUser.json
[{
"id": "user-1",
"username": "admin",
"password": "admin",
"level": 1
}, {
"id": "user-2",
"username": "monitor",
"password": "monitor",
"level": 2
},{
"id": "user-3",
"username": "test",
"password": "test",
"level": 2
}
]
pomelo-admin provides a simple auth function in pomelo-admin auth
developers can provide self-defined auth in pomelo by
in master server
1app.set('adminAuthUser', function(msg, cb){ 2 if(auth success) { 3 cb(user); 4 } else { 5 cb(null); 6 } 7})
##Server master auth
server connect to master with authorization
pomelo-admin provides a simple auth function in pomelo-admin auth
developers can provide self-defined auth in pomelo by
in master server
1app.set('adminAuthServerMaster', function(msg, cb){ 2 if(auth success) { 3 cb('ok'); 4 } else { 5 cb('bad'); 6 } 7})
in monitor server
1app.set('adminAuthServerMonitor', function(msg, cb){ 2 if(auth success) { 3 cb('ok'); 4 } else { 5 cb('bad'); 6 } 7})
note: by default you should provide adminServer.json file under the config dir
adminServer.json
[{
"type": "connector",
"token": "agarxhqb98rpajloaxn34ga8xrunpagkjwlaw3ruxnpaagl29w4rxn"
}, {
"type": "chat",
"token": "agarxhqb98rpajloaxn34ga8xrunpagkjwlaw3ruxnpaagl29w4rxn"
},{
"type": "gate",
"token": "agarxhqb98rpajloaxn34ga8xrunpagkjwlaw3ruxnpaagl29w4rxn"
}
]
type is the serverType, token is a string you can genrate by yourself
when using in pomelo, you should fill all your servers with type:token
pomelo-admin
provides a series of useful system modules by default. But most of them are turned off by default. Add a simple line of code in app.js
as below to enable them.
1app.configure('development', function() { 2 // enable the system monitor modules 3 app.enable('systemMonitor'); 4});
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
1 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More