1
クラスタリングした後、期待通りに機能せず、何度も何度も名前を聞いてください。Microsoftのボットフレームワークはスケーラブルではありませんか?
何か不足していますか?
ここは私のMicrosoftボットフレームワークのコードです。
server.js
var worker = require('./worker');
var cluster = require('cluster');
var spawnWorker = function() {
worker.createServer();
};
var createCluster = function() {
if(cluster.isMaster) {
var cpus = require('os').cpus().length;
for(var i = 0; i < cpus; i++) {
cluster.fork();
}
cluster.on('online', function(wkr) {
console.log('Worker started', wkr.process.pid);
});
cluster.on('exit', function(wkr) {
console.log('Worker died, respawing', wkr.process.pid);
cluster.fork();
});
} else {
spawnWorker();
}
};
createCluster();
worker.js
exports.createServer = function(){
var builder = require('botbuilder');
var connector = new builder.ConsoleConnector().listen();
var bot = new builder.UniversalBot(connector);
bot.dialog('/', [
function (session) {
builder.Prompts.text(session, process.pid+': Hi! What is your name?');
},
function (session, results) {
session.send(process.pid+':Hello %s!', results.response);
}
]);
}
出力
$ node server.js
Worker started 8540
Worker started 8068
Worker started 6020
Worker started 4244
8540: Hi! What is your name?
abc
8068: Hi! What is your name?
prq
6020: Hi! What is your name?
lmn
4244: Hi! What is your name?
xyz
詳しい情報here