Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
proteus-cluster
Advanced tools
Proteus Cluster is a module to use Node.js cluster module more conveniently.
This module collaborate with Proteus Logger to support logging under the clustered environment. See Proteus Logger for more detail.
The following are the features.
master implementation (cluster.js)
var cluster = require('proteus-cluster');
var conf = {};
conf.worker = 4;
conf.pid = '/tmp/proteus.pid';
conf.exec = 'worker.js';
conf.args = ['-c', 'config.json'];
conf.disconnectTimeout = 5000;
conf.maxForkCount = 30;
conf.api = {
listen : '0.0.0.0',
port : 8111
};
cluster(conf);
worker implementation (worker.js)
var express = require('express');
var app = express();
var port = 8080;
app.get('/', function(req, res) {
res.send('running worker '+process.pid);
});
app.listen(port);
run from shell
$ node cluster.js
$ ps ax | grep node | grep -v 'grep'
2051 s000 S+ 0:00.09 node cluster.js
2052 s000 R+ 0:00.42 node /proteus-cluster/test/worker.js
2053 s000 R+ 0:00.42 node /proteus-cluster/test/worker.js
$ kill -SIGUSR2 2051
run from program
cluster.restart();
run by calling API
curl http://localhost:8111/restart
run from shell
$ node cluster.js
$ ps ax | grep node | grep -v 'grep'
2051 s000 S+ 0:00.09 node cluster.js
2052 s000 R+ 0:00.42 node /proteus-cluster/test/worker.js
2053 s000 R+ 0:00.42 node /proteus-cluster/test/worker.js
$ kill -SIGINT 2051
run from program
cluster.shutdown();
run from program
cluster.forceShutdown();
worker implementation (worker.js)
process.send({cmd: 'fromWorker', msg: 'sending message to master'});
master implementation (cluster.js)
cluster.addMessageListener('fromWorker', function(msg) {
logger.debug(msg.msg); // sending message to master
});
// you can remove messageListener
cluster.removeMessageListener('fromWorker');
master implementation (cluster.js)
cluster.sendMessage({cmd: 'fromMaster', msg: 'sending message to worker'});
worker implementation (worker.js)
process.on('message', function(msg) {
logger.debug(msg.msg); // sending message to worker
});
Proteus Clusterは、Node.jsのclusterモジュールの利便性を高めたモジュールです。
Proteus Logger と連携し、node.js の cluster 環境におけるログ出力をサポートします。詳細は Proteus Logger をご参照下さい。
以下の特徴を持ちます。
masterの実装 (cluster.js)
var cluster = require('proteus-cluster');
var conf = {};
conf.worker = 4;
conf.pid = '/tmp/proteus.pid';
conf.exec = 'worker.js';
conf.args = ['-c', 'config.json'];
conf.disconnectTimeout = 5000;
conf.maxForkCount = 30;
conf.api = {
listen : '0.0.0.0',
port : 8111
};
cluster(conf);
workerの実装 (worker.js)
var express = require('express');
var app = express();
var port = 8080;
app.get('/', function(req, res) {
res.send('running worker '+process.pid);
});
app.listen(port);
シェルから実行
$ node cluster.js
$ ps ax | grep node | grep -v 'grep'
2051 s000 S+ 0:00.09 node cluster.js
2052 s000 R+ 0:00.42 node /proteus-cluster/test/worker.js
2053 s000 R+ 0:00.42 node /proteus-cluster/test/worker.js
$ kill -SIGUSR2 2051
プログラムから実行
cluster.restart();
APIを呼び出して実行
curl http://localhost:8111/restart
シェルから実行
$ node cluster.js
$ ps ax | grep node | grep -v 'grep'
2051 s000 S+ 0:00.09 node cluster.js
2052 s000 R+ 0:00.42 node /proteus-cluster/test/worker.js
2053 s000 R+ 0:00.42 node /proteus-cluster/test/worker.js
$ kill -SIGINT 2051
プログラムから実行
cluster.shutdown();
プログラムから実行
cluster.forceShutdown();
workerの実装 (worker.js)
process.send({cmd: 'fromWorker', msg: 'sending message to master'});
masterの実装 (cluster.js)
cluster.addMessageListener('fromWorker', function(msg) {
logger.info(msg.msg); // sending message to master
});
// messageListenerの削除も可能
cluster.removeMessageListener('fromWorker');
master implementation (cluster.js)
cluster.sendMessage({cmd: 'fromMaster', msg: 'sending message to worker'});
worker implementation (worker.js)
process.on('message', function(msg) {
logger.debug(msg.msg); // sending message to worker
});
Copyright 2012 CyberAgent, Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
FAQs
proteus-cluster ==============================
The npm package proteus-cluster receives a total of 2 weekly downloads. As such, proteus-cluster popularity was classified as not popular.
We found that proteus-cluster demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.