636da45832310feaa2ce8ec6016867ea7148ca38
[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 _0x8861=['send','index','getAllData','then','json','catch','components/import/cm','format','params','pid','split','length','Process\x20with\x20pid\x20%s\x20not\x20found!','kill','SIGINT','killProcess','systeminformation','child_process','exec','../../config/logger','util','bluebird','inspect','name','status'];(function(_0x2744e4,_0x2dbb98){var _0x1c5cb3=function(_0x54a3b2){while(--_0x54a3b2){_0x2744e4['push'](_0x2744e4['shift']());}};_0x1c5cb3(++_0x2dbb98);}(_0x8861,0x1eb));var _0x1886=function(_0x2041fc,_0x4a3794){_0x2041fc=_0x2041fc-0x0;var _0x3e6e46=_0x8861[_0x2041fc];return _0x3e6e46;};'use strict';var info=require(_0x1886('0x0'));var exec=require(_0x1886('0x1'))[_0x1886('0x2')];var logger=require(_0x1886('0x3'))('api');var util=require(_0x1886('0x4'));var BPromise=require(_0x1886('0x5'));var _=require('lodash');function handleError(_0x31f44e,_0xface6a,_0x504eef){_0xface6a=_0xface6a||0x1f4;return function(_0x146095){logger['error']('<%-\x20name\x20%>,\x20%s,\x20%s,\x20%s',_0x504eef,_0xface6a,util[_0x1886('0x6')](_0x146095,{'showHidden':![],'depth':null}));delete _0x146095[_0x1886('0x7')];_0x31f44e[_0x1886('0x8')](_0xface6a)[_0x1886('0x9')](_0x146095);};}exports[_0x1886('0xa')]=function(_0x5c58b6,_0x3bf164){return info[_0x1886('0xb')]()[_0x1886('0xc')](function(_0x5960af){return _0x3bf164[_0x1886('0x8')](0xc8)[_0x1886('0xd')](_0x5960af);})[_0x1886('0xe')](function(_0x120676){return _0x3bf164[_0x1886('0x8')](0x1f4)[_0x1886('0xd')](_0x120676);});};exports['killProcess']=function(_0x253de2,_0x5e0f51){var _0x4d21df=[_0x1886('0xf')];return new BPromise(function(_0x387a6d,_0x49d730){return exec(util[_0x1886('0x10')]('ps\x20-p\x20%s\x20-ww\x20-o\x20args',_0x253de2[_0x1886('0x11')][_0x1886('0x12')]),function(_0x290294,_0x3d85ad,_0x30e676){if(_0x290294){return _0x49d730(_0x290294);}return _0x387a6d(_0x3d85ad);});})[_0x1886('0xc')](function(_0x52c034){var _0x3c22f0=![];var _0x305f8c=_0x52c034[_0x1886('0x13')](/\n/);for(var _0x18b23a=0x0,_0x44faf7=_0x4d21df[_0x1886('0x14')];_0x18b23a<_0x44faf7,_0x3c22f0===![];_0x18b23a+=0x1){if(_0x52c034['indexOf'](_0x4d21df[_0x18b23a])>=0x0){_0x3c22f0=!![];}}if(!_0x3c22f0){throw new Error(util['format'](_0x1886('0x15'),_0x253de2[_0x1886('0x11')]['pid']));}process[_0x1886('0x16')](_0x253de2[_0x1886('0x11')][_0x1886('0x12')],_0x1886('0x17'));return _0x5e0f51[_0x1886('0x8')](0xc8)[_0x1886('0xd')]({'message':util[_0x1886('0x10')]('Process\x20with\x20pid\x20%s\x20killed\x20correctly',_0x253de2[_0x1886('0x11')][_0x1886('0x12')])});})[_0x1886('0xe')](handleError(_0x5e0f51,null,_0x1886('0x18')));};