1e2e68a78af9ba570e1968558cb1029920fa8b43
[motion2.git] / server / api / system / system.controller.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0xeb33=['systeminformation','child_process','exec','api','<%-\x20name\x20%>,\x20%s,\x20%s,\x20%s','inspect','status','send','index','then','json','catch','components/import/cm','format','Process\x20with\x20pid\x20%s\x20not\x20found!','params','pid','SIGINT','Process\x20with\x20pid\x20%s\x20killed\x20correctly','killProcess'];(function(_0x3c1501,_0x463ab9){var _0x505ef2=function(_0x54dd37){while(--_0x54dd37){_0x3c1501['push'](_0x3c1501['shift']());}};_0x505ef2(++_0x463ab9);}(_0xeb33,0xf0));var _0x3eb3=function(_0x5ab1f7,_0x2af4e7){_0x5ab1f7=_0x5ab1f7-0x0;var _0x5b3d88=_0xeb33[_0x5ab1f7];return _0x5b3d88;};'use strict';var info=require(_0x3eb3('0x0'));var exec=require(_0x3eb3('0x1'))[_0x3eb3('0x2')];var logger=require('../../config/logger')(_0x3eb3('0x3'));var util=require('util');var BPromise=require('bluebird');var _=require('lodash');function handleError(_0x308b10,_0x176657,_0x39f1f8){_0x176657=_0x176657||0x1f4;return function(_0x2c4337){logger['error'](_0x3eb3('0x4'),_0x39f1f8,_0x176657,util[_0x3eb3('0x5')](_0x2c4337,{'showHidden':![],'depth':null}));delete _0x2c4337['name'];_0x308b10[_0x3eb3('0x6')](_0x176657)[_0x3eb3('0x7')](_0x2c4337);};}exports[_0x3eb3('0x8')]=function(_0x34bbe1,_0x4757cd){return info['getAllData']()[_0x3eb3('0x9')](function(_0x50d9cc){return _0x4757cd['status'](0xc8)[_0x3eb3('0xa')](_0x50d9cc);})[_0x3eb3('0xb')](function(_0x46e17a){return _0x4757cd[_0x3eb3('0x6')](0x1f4)[_0x3eb3('0xa')](_0x46e17a);});};exports['killProcess']=function(_0x26c487,_0x378c47){var _0x595d7d=[_0x3eb3('0xc')];return new BPromise(function(_0x4a9cd0,_0x9a2183){return exec(util['format']('ps\x20-p\x20%s\x20-ww\x20-o\x20args',_0x26c487['params']['pid']),function(_0x58a865,_0x4f0a5f,_0x3ae484){if(_0x58a865){return _0x9a2183(_0x58a865);}return _0x4a9cd0(_0x4f0a5f);});})['then'](function(_0x1e7375){var _0xca4ed5=![];var _0x12aeab=_0x1e7375['split'](/\n/);for(var _0xa96ea5=0x0,_0x44362f=_0x595d7d['length'];_0xa96ea5<_0x44362f,_0xca4ed5===![];_0xa96ea5+=0x1){if(_0x1e7375['indexOf'](_0x595d7d[_0xa96ea5])>=0x0){_0xca4ed5=!![];}}if(!_0xca4ed5){throw new Error(util[_0x3eb3('0xd')](_0x3eb3('0xe'),_0x26c487[_0x3eb3('0xf')][_0x3eb3('0x10')]));}process['kill'](_0x26c487['params'][_0x3eb3('0x10')],_0x3eb3('0x11'));return _0x378c47[_0x3eb3('0x6')](0xc8)[_0x3eb3('0xa')]({'message':util['format'](_0x3eb3('0x12'),_0x26c487[_0x3eb3('0xf')]['pid'])});})[_0x3eb3('0xb')](handleError(_0x378c47,null,_0x3eb3('0x13')));};