senecajs / seneca

A microservices toolkit for Node.js.
http://senecajs.org
MIT License
3.96k stars 312 forks source link

SENECA TERMINATED #668

Closed chiragob closed 7 years ago

chiragob commented 7 years ago

we created one job queue service its working fine when we set valid connection option. but when rethinkdb crash at that time error will be throw and we handle with try catch but after some time seneca service is crash. please help us. how to handle this issue.

=============job.js=========== const Queue = require('rethinkdb-job-queue') const defaultConnectionOptions = { host: 'localhost', port: 28016, db: 'jobQueue' } const defaultQueueOption = { name: 'SendEmail' } module.exports = function job (options) { options = this.util.deepextend({ queueOption: defaultQueueOption, connctionOption: defaultConnectionOptions }, options)

this.add('role:job,cmd:create', async function emailSend (msg, response) { let {err, result} = await createRethinkJobQueue(msg) response(err, result) })

let createRethinkJobQueue = async function (qdata) { try { let queueObj = await createJobQueue(options.connctionOption, options.queueOption) queueObj.on('error', (err) => { throw err }) let job = await createJob(queueObj, { data: qdata }) //console.log(job) let savedJobs await addJob(queueObj, job).then(result => { savedJobs = {'jobId': result[0].id} }) .catch (err => { throw err }) return {err:null, result:savedJobs} } catch (err) { err1 = customError(err) return {err:err1, result:null} } }

let createJobQueue = function (connctionOption, queueOption) { try { return new Queue(connctionOption, queueOption) } catch (e) { throw (e) } }

let createJob = async function (queueObj, QData) { try { return await queueObj.createJob({data: QData}) } catch (e) { throw (e) } }

let addJob = async function (queueObj, job) { return new Promise(async (resolve, reject) => { try { await queueObj.addJob(job) .catch(err => { throw err }) .then(result => resolve(result)) } catch (err) { reject(err) } }) } }

let customError = function (err, errorCode) { let errRes = {} errRes['error'] = { 'message': err.message || 'Service Not avaialble' } errRes['status'] = errorCode || 404 return errRes }

===========service.js=================== var seneca = require('seneca') seneca({tag:'job'}) .use('job') .use('mesh', { isbase: true, listen: [ {timeout: 999999, pin: 'role:job,cmd:create'} ] }) .ready(function(){ console.log("job ready") }) =============client.js================= let senecaObj = require('seneca') let bodyData = { "to":"test@mymail.com", "from":"pqr@mymail.com", "subject":"this is test mail", "body":"this is message body" } senecaObj() .use('mesh',{timeout: 999999}) .act({role: 'job', cmd: 'create'}, bodyData, (err, done) => { if (err) { throw err } console.log('test-mesh done. job created = ', done) })

======================================================================== its throw error and we catch error using queue.on error event. but its carsh when server

{ ReqlDriverError: None of the pools have an opened connection and failed to open a new one at /var/www/html/node/seneca-email/node_modules/rethinkdbdash/lib/pool_master.js:130:14 at Promise._execute (/var/www/html/node/seneca-email/node_modules/bluebird/js/release/debuggability.js:300:9) at Promise._resolveFromExecutor (/var/www/html/node/seneca-email/node_modules/bluebird/js/release/promise.js:483:18) at new Promise (/var/www/html/node/seneca-email/node_modules/bluebird/js/release/promise.js:79:10) at PoolMaster.getConnection (/var/www/html/node/seneca-email/node_modules/rethinkdbdash/lib/pool_master.js:129:12) at /var/www/html/node/seneca-email/node_modules/rethinkdbdash/lib/term.js:143:20 at Promise._execute (/var/www/html/node/seneca-email/node_modules/bluebird/js/release/debuggability.js:300:9) at Promise._resolveFromExecutor (/var/www/html/node/seneca-email/node_modules/bluebird/js/release/promise.js:483:18) at new Promise (/var/www/html/node/seneca-email/node_modules/bluebird/js/release/promise.js:79:10) at Function.Term.run (/var/www/html/node/seneca-email/node_modules/rethinkdbdash/lib/term.js:142:15) at /var/www/html/node/seneca-email/node_modules/rethinkdb-job-queue/dist/db-assert-database.js:11:8 at tryCatcher (/var/www/html/node/seneca-email/node_modules/bluebird/js/release/util.js:16:23) at Promise._settlePromiseFromHandler (/var/www/html/node/seneca-email/node_modules/bluebird/js/release/promise.js:512:31) at Promise._settlePromise (/var/www/html/node/seneca-email/node_modules/bluebird/js/release/promise.js:569:18) at Promise._settlePromiseCtx (/var/www/html/node/seneca-email/node_modules/bluebird/js/release/promise.js:606:10) at Async._drainQueue (/var/www/html/node/seneca-email/node_modules/bluebird/js/release/async.js:138:12) msg: 'None of the pools have an opened connection and failed to open a new one', message: 'None of the pools have an opened connection and failed to open a new one.', isOperational: true, queueId: 'oblap28:jobQueue:SendEmail:16875:dd2aa7d1-7d34-46b8-8558-79e2b805cf9f' }

{"notice":"seneca: act_execute","code":"unknown","err":{"eraro":true,"orig":null,"code":"unknown","seneca":true,"package":"seneca","msg":"seneca: act_execute","details":{"pattern":"cmd:create,role:job","instance":"Seneca/0rtxmbcenmag/1501831435434/16875/3.3.0/job","plugin":{}},"callpoint":"at act_error (/var/www/html/node/seneca-email/node_modules/seneca/seneca.js:1208:13)"},"actid":"jvbugxk27gs5/m53gnoqj7gfu","msg":{"host":"smtp.gmail.com","port":465,"secure":true,"user":"obsoftcare@gmail.com","password":"Welcome123@","to":"abcd@vmail.officebrain.com","from":"info@vmail.officebrain.com","subject":"this is test mail","body":"this is message body","role":"job","cmd":"create","transport$":{"track":["wilqd0zda5yf/1501831440490/16884/3.3.0/-"],"origin":"wilqd0zda5yf/1501831440490/16884/3.3.0/-","time":{"client_sent":"1501831442717"}},"plugin$":{"name":"mesh"},"fatal$":true,"tx$":"k5v64km4pt0b","meta$":{"mi":"yform8z6cn9d","tx":"k5v64km4pt0b","id":"yform8z6cn9d/k5v64km4pt0b","pattern":"cmd:create,role:job","action":"(smds24ljnsya)","plugin_name":"root$","prior":{"chain":[],"entry":true,"depth":0},"start":1501831442737,"sync":true}},"entry":true,"prior":[],"meta":{"raw":{"role":"job","cmd":"create"},"plugin_name":"root$","plugin_fullname":"root$","sub":false,"client":false,"args":{"role":"job","cmd":"create"},"rules":{},"id":"(smds24ljnsya)","pattern":"cmd:create,role:job","msgcanon":{"cmd":"create","role":"job"},"priorpath":""},"client":false,"listen":true,"transport":{"track":["wilqd0zda5yf/1501831440490/16884/3.3.0/-"],"origin":"wilqd0zda5yf/1501831440490/16884/3.3.0/-","time":{"client_sent":"1501831442717"}},"kind":"act","case":"ERR","duration":676,"level":"error","plugin_name":"mesh","pattern":"hook:listen,role:transport,type:web","when":1501831443419} []

Seneca Fatal Error

Message: seneca: act_execute

Code: unknown

Details: { message: undefined, pattern: 'cmd:create,role:job', fn: { [AsyncFunction: emailSend] plugin_name: 'job', plugin_tag: '-', plugin_fullname: 'job', log: { [Function: prepare_log_data] debug: [Function: prepare_log_data], info: [Function: prepare_log_data], warn: [Function: prepare_log_data], error: [Function: prepare_log_data], fatal: [Function: prepare_log_data] } }, cb: [Function], instance: 'Seneca/0rtxmbcenmag/1501831435434/16875/3.3.0/job', plugin: {} }

Stack: at errormaker (/var/www/html/node/seneca-email/node_modules/eraro/eraro.js:94:15) at act_error (/var/www/html/node/seneca-email/node_modules/seneca/seneca.js:1208:13) at Seneca.handle_result (/var/www/html/node/seneca-email/node_modules/seneca/seneca.js:1116:19) at Seneca.reply (/var/www/html/node/seneca-email/node_modules/seneca/seneca.js:1029:29) at Seneca.emailSend (/var/www/html/node/seneca-email/job.js:25:5) at process._tickCallback (internal/process/next_tick.js:109:7)

Instance: Seneca/0rtxmbcenmag/1501831435434/16875/3.3.0/job ALL ERRORS FATAL: action called with argument fatal$:true (probably a plugin init error, or using a plugin seneca instance) at Seneca.handle_result (/var/www/html/node/seneca-email/node_modules/seneca/seneca.js:1120:27)

When: 2017-08-04T07:24:03.423Z

Log: {kind:null,plugin:seneca,tag:3.3.0,id:0rtxmbcenmag/1501831435434/16875/3.3.0/job,code:unknown,notice:seneca: ac

Node: { http_parser: '2.7.0', node: '7.9.0', v8: '5.5.372.43', uv: '1.11.0', zlib: '1.2.11', ares: '1.10.1-DEV', modules: '51', openssl: '1.0.2k', icu: '58.2', unicode: '9.0', cldr: '30.0.3', tz: '2016j' }, { debug: false, uv: true, ipv6: true, tls_npn: true, tls_alpn: true, tls_sni: true, tls_ocsp: true, tls: true }, [ 'Binding contextify', 'Binding natives', 'NativeModule events', 'Binding config', 'Binding icu', 'NativeModule util', 'Binding uv', 'NativeModule buffer', 'Binding buffer', 'Binding util', 'NativeModule internal/util', 'NativeModule internal/buffer', 'NativeModule timers', 'Binding timer_wrap', 'NativeModule internal/linkedlist', 'NativeModule assert', 'NativeModule internal/process', 'NativeModule internal/process/warning', 'NativeModule internal/process/next_tick', 'NativeModule internal/process/promises', 'NativeModule internal/process/stdio', 'Binding constants', 'NativeModule path', 'NativeModule module', 'NativeModule internal/module', 'NativeModule vm', 'NativeModule fs', 'Binding fs', 'NativeModule stream', 'NativeModule internal/streams/legacy', 'NativeModule _stream_readable', 'NativeModule internal/streams/BufferList', 'NativeModule _stream_writable', 'NativeModule _stream_duplex', 'NativeModule _stream_transform', 'NativeModule _stream_passthrough', 'Binding fs_event_wrap', 'NativeModule internal/fs', 'NativeModule internal/url', 'NativeModule internal/querystring', 'Binding url', 'NativeModule querystring', 'NativeModule os', 'Binding os', 'NativeModule net', 'NativeModule internal/net', 'Binding cares_wrap', 'Binding tty_wrap', 'Binding tcp_wrap', 'Binding pipe_wrap', 'Binding stream_wrap', 'NativeModule http', 'NativeModule _http_incoming', 'NativeModule _http_outgoing', 'NativeModule _http_common', 'Binding http_parser', 'NativeModule internal/freelist', 'NativeModule _http_agent', 'NativeModule _http_server', 'NativeModule _http_client', 'NativeModule url', 'NativeModule https', 'NativeModule tls', 'Binding crypto', 'NativeModule _tls_common', 'NativeModule _tls_wrap', 'NativeModule crypto', 'NativeModule internal/streams/lazy_transform', 'NativeModule string_decoder', 'NativeModule _stream_wrap', 'Binding js_stream', 'Binding tls_wrap', 'NativeModule _tls_legacy', 'NativeModule tty', 'Binding signal_wrap', 'NativeModule console', 'NativeModule dgram', 'Binding udp_wrap', 'NativeModule dns', 'NativeModule cluster', 'NativeModule internal/cluster/master', 'NativeModule child_process', 'Binding spawn_sync', 'NativeModule internal/child_process', 'Binding process_wrap', 'NativeModule internal/socket_list', 'NativeModule internal/cluster/round_robin_handle', 'NativeModule internal/cluster/utils', 'NativeModule internal/cluster/shared_handle', 'NativeModule internal/cluster/worker' ]

Process: pid=16875, arch=x64, platform=linux, path=/usr/bin/nodejs, argv=[ '/usr/bin/nodejs', '/var/www/html/node/seneca-email/server.js' ], env={ XDG_VTNR: '7', XDG_SESSION_ID: 'c2', CLUTTER_IM_MODULE: 'xim', XDG_GREETER_DATA_DIR: '/var/lib/lightdm-data/software', SESSION: 'ubuntu', GPG_AGENT_INFO: '/home/software/.gnupg/S.gpg-agent:0:1', SHELL: '/bin/bash', TERM: 'xterm-256color', VTE_VERSION: '4205', QT_LINUX_ACCESSIBILITY_ALWAYS_ON: '1', WINDOWID: '75497482', UPSTART_SESSION: 'unix:abstract=/com/ubuntu/upstart-session/1001/2493', GNOME_KEYRING_CONTROL: '', GTK_MODULES: 'gail:atk-bridge:unity-gtk-module', USER: 'software', QT_ACCESSIBILITY: '1', XDG_SESSION_PATH: '/org/freedesktop/DisplayManager/Session0', XDG_SEAT_PATH: '/org/freedesktop/DisplayManager/Seat0', SSH_AUTH_SOCK: '/run/user/1001/keyring/ssh', DEFAULTS_PATH: '/usr/share/gconf/ubuntu.default.path', XDG_CONFIG_DIRS: '/etc/xdg/xdg-ubuntu:/usr/share/upstart/xdg:/etc/xdg', PATH: '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin', DESKTOP_SESSION: 'ubuntu', QT_IM_MODULE: 'ibus', QT_QPA_PLATFORMTHEME: 'appmenu-qt5', XDG_SESSION_TYPE: 'x11', PWD: '/var/www/html/node/seneca-email', JOB: 'unity-settings-daemon', XMODIFIERS: '@im=ibus', GNOME_KEYRING_PID: '', LANG: 'en_IN', GDM_LANG: 'en_US', MANDATORY_PATH: '/usr/share/gconf/ubuntu.mandatory.path', IM_CONFIG_PHASE: '1', COMPIZ_CONFIG_PROFILE: 'ubuntu', GDMSESSION: 'ubuntu', SESSIONTYPE: 'gnome-session', GTK2_MODULES: 'overlay-scrollbar', HOME: '/home/software', XDG_SEAT: 'seat0', SHLVL: '1', LANGUAGE: 'en_IN:en', GNOME_DESKTOP_SESSION_ID: 'this-is-deprecated', UPSTART_INSTANCE: '', UPSTART_EVENTS: 'xsession started', XDG_SESSION_DESKTOP: 'ubuntu', LOGNAME: 'software', COMPIZ_BIN_PATH: '/usr/bin/', QT4_IM_MODULE: 'xim', XDG_DATA_DIRS: '/usr/share/ubuntu:/usr/share/gnome:/usr/local/share/:/usr/share/:/var/lib/snapd/desktop', DBUS_SESSION_BUS_ADDRESS: 'unix:abstract=/tmp/dbus-vrAjPpiPLe', INSTANCE: '', UPSTART_JOB: 'unity7', XDG_RUNTIME_DIR: '/run/user/1001', DISPLAY: ':0', XDG_CURRENT_DESKTOP: 'Unity', GTK_IMMODULE: 'ibus', XAUTHORITY: '/home/software/.Xauthority', OLDPWD: '/var/www/html/node', : '/usr/bin/node' }

SENECA TERMINATED at 2017-08-04T07:24:03.430Z. See above for error report.

chiragob commented 7 years ago

issue resolved