How to use the pinus-robot.Robot function in pinus-robot

To help you get started, we’ve selected a few pinus-robot examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github node-pinus / pinus / plugins / pinus-robot-plugin / src / robotAgent.ts View on Github external
import { Application , IPlugin} from 'pinus';
import { Robot, RobotCfg } from 'pinus-robot';
import * as  fs from 'fs';
import * as yargs from 'yargs';
let argv = yargs.argv;

console.log('启动robotAgent');

let config = {
    master: {host: argv.host, port: argv.port, interval: argv.interval}
} as RobotCfg;

let robot = new Robot(config);
robot.runAgent(argv.scriptFile as any);

process.on('uncaughtException', function (err) {
    console.error(' Caught exception: ' + err.stack);
    if (!!robot && !!robot.agent) {
    // robot.agent.socket.emit('crash', err.stack);
    }
    fs.appendFile('./log/.log', err.stack, function (err) { });
});
github node-pinus / pinus / plugins / pinus-robot-plugin / src / robotPlugin.ts View on Github external
afterStartAll(app: Application): void {
        let robot = new Robot(this.conf);
        let mode = 'master';
        let scriptFile = path.normalize(this.conf.scriptFile);
        if(path.sep === '\\') {
            scriptFile = scriptFile.replace(/\\/g , '\\\\');
        }
        // 启动机器人总管
        robot.runMaster(`"${__dirname}/robotAgent.js" --host=${this.conf.master.host} --port=${this.conf.master.port} --interval=${this.conf.master.interval} --scriptFile="${scriptFile}"`);
    }
}
github node-pinus / pinus / examples / robot-sample / http.ts View on Github external
import * as http from 'http';
let envConfig = require('./app/config/env.json');
let config = require('./app/config/' + envConfig.env + '/config');
let path = __filename.substring(0, __filename.lastIndexOf('/'));
import { Robot } from 'pinus-robot';
import * as cluster from 'cluster';

let robot = new Robot(config);

function run(num) {
    for (let i = 0; i < num; i++) {
        cluster.fork();
    }
}

function stop() {
    for (let id in cluster.workers) {
        cluster.workers[id].process.kill();
    }
}

function startHttp() {
    http.createServer(function (req, res) {
        if (req.method === 'GET') {
github node-pinus / pinus / examples / robot-sample / app.ts View on Github external
let envConfig = require('./app/config/env.json');
let config = require('./app/config/' + envConfig.env + '/config');
import { Robot } from 'pinus-robot';
import * as  fs from 'fs';

let robot = new Robot(config);
let mode = 'master';

if (process.argv.length > 2) {
    mode = process.argv[2];
}

if (mode !== 'master' && mode !== 'client') {
    throw new Error(' mode must be master or client');
}

if (mode === 'master') {
    robot.runMaster(__filename);
} else {
    let script = (process.cwd() + envConfig.script);
    robot.runAgent(script);
}

pinus-robot

pinus-robot is a simple tool to benchmark the socket.io server's performance.

MIT
Latest version published 3 months ago

Package Health Score

72 / 100
Full package analysis

Popular pinus-robot functions