prompt({ type: 'input', name: 'color', message: 'Favorite color?' }) .then(answers => { console.info(answers); process.exit(0); });
const onExit = (quit, code) => { if (called) return; called = true; fns.forEach(fn => fn()); if (quit === true) { process.exit(128 + code); } }
prompt.on('cancel', () => process.exit());
/** * create acceptor * * @param opts init params * @param cb(tracer, msg, cb) callback function that would be invoked when new message arrives */ export function create(opts: AcceptorOpts, cb: (tracer: Tracer, msg?: any, cb?: Function) => void) { return new TCPAcceptor(opts || <any>{}, cb); } process.on('SIGINT', function () { process.exit(); });
/** * Add server to application. * * @param {Object} opts options for `add` operation */ function add(opts: any) { let id = 'pinus_add_' + Date.now(); connectToMaster(id, opts, function (client) { client.request(co.moduleId, { signal: 'add', args: opts.args }, function (err: Error) { if (err) { console.error(err); } else { console.info(ADD_SERVER_INFO); } process.exit(0); }); }); }
function connectToMaster(id, opts) { client = new adminClient({username: opts.username, password: opts.password, md5: opts.md5}); client.connect(id, opts.host, opts.port,function(err) { if(err) { client = null; console.error(err); process.exit(1); } }); client.on('error', function () { client = null; }); client.on('close', function () { client = null; }); client.on('disconnect', function() { client = null; }); }
function restart(opts: any) { let id = 'pinus_restart_' + Date.now(); let serverIds: string[] = []; let type: string = null; if (!!opts.id) { serverIds.push(opts.id); } if (!!opts.type) { type = opts.type; } connectToMaster(id, opts, function (client) { client.request(co.moduleId, { signal: 'restart', ids: serverIds, type: type }, function (err: Error, fails: string[]) { if (!!err) { console.error(err); } else if (!!fails.length) { console.info('restart fails server ids: %j', fails); } else { console.info(RESTART_SERVER_INFO); } process.exit(0); }); }); }
process.exit(-1); }, Constants.TIME.TIME_WAIT_MONITOR_KILL); });
export default function doConnect() { client = new AdminClient({ username: username, password: password, md5: true }); let id = 'pinus_cli_' + Date.now(); client.connect(id, host, port, function (err: Error) { if (err) { util.log('\n' + err + '\n'); process.exit(0); } else { let ASCII_LOGO = consts.ASCII_LOGO; for (let i = 0; i < ASCII_LOGO.length; i++) { util.log(ASCII_LOGO[i]); } let WELCOME_INFO = consts.WELCOME_INFO; for (let i = 0, l = WELCOME_INFO.length; i < l; i++) { util.log(WELCOME_INFO[i]); } startCli(); } }); client.on('close', function () { client.socket.disconnect(); util.log('\ndisconnect from master'); process.exit(0); }); }
/** * Exit with the given `str`. * * @param {String} str */ export function abort(str: string) { console.error(str); process.exit(1); }
stop() { this.server.close(); process.exit(0); }
}); console.log(cliff.stringifyRows(rows, ['red', 'blue', 'green', 'cyan', 'magenta', 'white', 'yellow'])); process.exit(0); }); });
exit() { logger.info('exit ...'); process.exit(0); }
/** * create acceptor * * @param opts init params * @param cb(tracer, msg, cb) callback function that would be invoked when new message arrives */ export function create(opts: AcceptorOpts, cb: (tracer: Tracer, msg?: any, cb?: Function) => void) { return new TCPAcceptor(opts || <any>{}, cb); } process.on('SIGINT', function () { process.exit(); });
function connectToMaster(id, opts) { client = new adminClient({username: opts.username, password: opts.password, md5: opts.md5}); client.connect(id, opts.host, opts.port,function(err) { if(err) { client = null; console.error(err); process.exit(1); } }); client.on('error', function () { client = null; }); client.on('close', function () { client = null; }); client.on('disconnect', function() { client = null; }); }