ff67e0f47394dc5f6f657622d28754bf2997df7c
[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 _0x1269=['components/import/cm','ps\x20-p\x20%s\x20-ww\x20-o\x20args','params','then','split','length','pid','SIGINT','Process\x20with\x20pid\x20%s\x20killed\x20correctly','catch','child_process','exec','api','util','bluebird','lodash','error','name','status','index','json','killProcess'];(function(_0x1024d2,_0x4df209){var _0x4aa07b=function(_0x1fe86a){while(--_0x1fe86a){_0x1024d2['push'](_0x1024d2['shift']());}};_0x4aa07b(++_0x4df209);}(_0x1269,0xd0));var _0x9126=function(_0x41b8f2,_0x1ebe99){_0x41b8f2=_0x41b8f2-0x0;var _0x555e15=_0x1269[_0x41b8f2];return _0x555e15;};'use strict';var info=require('systeminformation');var exec=require(_0x9126('0x0'))[_0x9126('0x1')];var logger=require('../../config/logger')(_0x9126('0x2'));var util=require(_0x9126('0x3'));var BPromise=require(_0x9126('0x4'));var _=require(_0x9126('0x5'));function handleError(_0x5426e6,_0x3b62bc,_0x57696d){_0x3b62bc=_0x3b62bc||0x1f4;return function(_0x39db5e){logger[_0x9126('0x6')]('<%-\x20name\x20%>,\x20%s,\x20%s,\x20%s',_0x57696d,_0x3b62bc,util['inspect'](_0x39db5e,{'showHidden':![],'depth':null}));delete _0x39db5e[_0x9126('0x7')];_0x5426e6[_0x9126('0x8')](_0x3b62bc)['send'](_0x39db5e);};}exports[_0x9126('0x9')]=function(_0xb45ef9,_0x27e872){return info['getAllData']()['then'](function(_0x5ea610){return _0x27e872['status'](0xc8)['json'](_0x5ea610);})['catch'](function(_0x50da7e){return _0x27e872['status'](0x1f4)[_0x9126('0xa')](_0x50da7e);});};exports[_0x9126('0xb')]=function(_0x30b8fb,_0x45415a){var _0x6ed350=[_0x9126('0xc')];return new BPromise(function(_0x4ca233,_0x59acc6){return exec(util['format'](_0x9126('0xd'),_0x30b8fb[_0x9126('0xe')]['pid']),function(_0x6466d3,_0x1e4b90,_0xa899df){if(_0x6466d3){return _0x59acc6(_0x6466d3);}return _0x4ca233(_0x1e4b90);});})[_0x9126('0xf')](function(_0x2d4ff2){var _0x4a018d=![];var _0x294300=_0x2d4ff2[_0x9126('0x10')](/\n/);for(var _0x496151=0x0,_0x4af936=_0x6ed350[_0x9126('0x11')];_0x496151<_0x4af936,_0x4a018d===![];_0x496151+=0x1){if(_0x2d4ff2['indexOf'](_0x6ed350[_0x496151])>=0x0){_0x4a018d=!![];}}if(!_0x4a018d){throw new Error(util['format']('Process\x20with\x20pid\x20%s\x20not\x20found!',_0x30b8fb[_0x9126('0xe')][_0x9126('0x12')]));}process['kill'](_0x30b8fb[_0x9126('0xe')][_0x9126('0x12')],_0x9126('0x13'));return _0x45415a[_0x9126('0x8')](0xc8)[_0x9126('0xa')]({'message':util['format'](_0x9126('0x14'),_0x30b8fb[_0x9126('0xe')][_0x9126('0x12')])});})[_0x9126('0x15')](handleError(_0x45415a,null,'killProcess'));};