0a075bf5668bde6aa96e6ad423c1e00e91d3d789
[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 _0x1d56=['format','params','pid','then','split','length','indexOf','Process\x20with\x20pid\x20%s\x20not\x20found!','kill','Process\x20with\x20pid\x20%s\x20killed\x20correctly','catch','systeminformation','exec','util','bluebird','lodash','error','inspect','name','index','getAllData','status','json','killProcess','components/import/cm'];(function(_0x2071cc,_0x5d728e){var _0x31aa5d=function(_0x2febbd){while(--_0x2febbd){_0x2071cc['push'](_0x2071cc['shift']());}};_0x31aa5d(++_0x5d728e);}(_0x1d56,0x105));var _0x61d5=function(_0x4b6644,_0x18bac5){_0x4b6644=_0x4b6644-0x0;var _0x9f37c=_0x1d56[_0x4b6644];return _0x9f37c;};'use strict';var info=require(_0x61d5('0x0'));var exec=require('child_process')[_0x61d5('0x1')];var logger=require('../../config/logger')('api');var util=require(_0x61d5('0x2'));var BPromise=require(_0x61d5('0x3'));var _=require(_0x61d5('0x4'));function handleError(_0x2665cb,_0x4ff0ee,_0x526f63){_0x4ff0ee=_0x4ff0ee||0x1f4;return function(_0xa9d1ad){logger[_0x61d5('0x5')]('<%-\x20name\x20%>,\x20%s,\x20%s,\x20%s',_0x526f63,_0x4ff0ee,util[_0x61d5('0x6')](_0xa9d1ad,{'showHidden':![],'depth':null}));delete _0xa9d1ad[_0x61d5('0x7')];_0x2665cb['status'](_0x4ff0ee)['send'](_0xa9d1ad);};}exports[_0x61d5('0x8')]=function(_0x304308,_0x5b9572){return info[_0x61d5('0x9')]()['then'](function(_0x56ff97){return _0x5b9572['status'](0xc8)['json'](_0x56ff97);})['catch'](function(_0x58ceb5){return _0x5b9572[_0x61d5('0xa')](0x1f4)[_0x61d5('0xb')](_0x58ceb5);});};exports[_0x61d5('0xc')]=function(_0x4b3491,_0x1c0639){var _0x3b6266=[_0x61d5('0xd')];return new BPromise(function(_0x3a0fcc,_0x2adc58){return exec(util[_0x61d5('0xe')]('ps\x20-p\x20%s\x20-ww\x20-o\x20args',_0x4b3491[_0x61d5('0xf')][_0x61d5('0x10')]),function(_0x16c0c1,_0x336e31,_0x2cc6bd){if(_0x16c0c1){return _0x2adc58(_0x16c0c1);}return _0x3a0fcc(_0x336e31);});})[_0x61d5('0x11')](function(_0x57a1f6){var _0x49f04c=![];var _0x54fa4d=_0x57a1f6[_0x61d5('0x12')](/\n/);for(var _0x5c5491=0x0,_0x3b0077=_0x3b6266[_0x61d5('0x13')];_0x5c5491<_0x3b0077,_0x49f04c===![];_0x5c5491+=0x1){if(_0x57a1f6[_0x61d5('0x14')](_0x3b6266[_0x5c5491])>=0x0){_0x49f04c=!![];}}if(!_0x49f04c){throw new Error(util[_0x61d5('0xe')](_0x61d5('0x15'),_0x4b3491['params'][_0x61d5('0x10')]));}process[_0x61d5('0x16')](_0x4b3491[_0x61d5('0xf')][_0x61d5('0x10')],'SIGINT');return _0x1c0639[_0x61d5('0xa')](0xc8)[_0x61d5('0xb')]({'message':util['format'](_0x61d5('0x17'),_0x4b3491['params']['pid'])});})[_0x61d5('0x18')](handleError(_0x1c0639,null,'killProcess'));};