0c13f38a6b76423d7315f6521b2d9f48cff905e5
[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 _0xb201=['name','status','send','index','getAllData','then','json','catch','format','ps\x20-p\x20%s\x20-ww\x20-o\x20args','params','pid','kill','SIGINT','killProcess','systeminformation','exec','../../config/logger','util','bluebird','lodash','<%-\x20name\x20%>,\x20%s,\x20%s,\x20%s'];(function(_0x36eb36,_0x230a1e){var _0x5e25af=function(_0x1ea8af){while(--_0x1ea8af){_0x36eb36['push'](_0x36eb36['shift']());}};_0x5e25af(++_0x230a1e);}(_0xb201,0x117));var _0x1b20=function(_0x33146e,_0x2d07a4){_0x33146e=_0x33146e-0x0;var _0x390b00=_0xb201[_0x33146e];return _0x390b00;};'use strict';var info=require(_0x1b20('0x0'));var exec=require('child_process')[_0x1b20('0x1')];var logger=require(_0x1b20('0x2'))('api');var util=require(_0x1b20('0x3'));var BPromise=require(_0x1b20('0x4'));var _=require(_0x1b20('0x5'));function handleError(_0x57a68c,_0x48818a,_0xd76d73){_0x48818a=_0x48818a||0x1f4;return function(_0x36dbbb){logger['error'](_0x1b20('0x6'),_0xd76d73,_0x48818a,util['inspect'](_0x36dbbb,{'showHidden':![],'depth':null}));delete _0x36dbbb[_0x1b20('0x7')];_0x57a68c[_0x1b20('0x8')](_0x48818a)[_0x1b20('0x9')](_0x36dbbb);};}exports[_0x1b20('0xa')]=function(_0x26e126,_0x485976){return info[_0x1b20('0xb')]()[_0x1b20('0xc')](function(_0x14d11f){return _0x485976[_0x1b20('0x8')](0xc8)[_0x1b20('0xd')](_0x14d11f);})[_0x1b20('0xe')](function(_0x25e06a){return _0x485976[_0x1b20('0x8')](0x1f4)['json'](_0x25e06a);});};exports['killProcess']=function(_0x7aac13,_0x3cb78c){var _0x452da4=['components/import/cm'];return new BPromise(function(_0x1d7fcf,_0x4b7c2d){return exec(util[_0x1b20('0xf')](_0x1b20('0x10'),_0x7aac13[_0x1b20('0x11')]['pid']),function(_0x3ca751,_0x4135bb,_0x5908ec){if(_0x3ca751){return _0x4b7c2d(_0x3ca751);}return _0x1d7fcf(_0x4135bb);});})['then'](function(_0x16aa9f){var _0x588dbe=![];var _0x1a66e5=_0x16aa9f['split'](/\n/);for(var _0x35aad0=0x0,_0x2be1ed=_0x452da4['length'];_0x35aad0<_0x2be1ed,_0x588dbe===![];_0x35aad0+=0x1){if(_0x16aa9f['indexOf'](_0x452da4[_0x35aad0])>=0x0){_0x588dbe=!![];}}if(!_0x588dbe){throw new Error(util[_0x1b20('0xf')]('Process\x20with\x20pid\x20%s\x20not\x20found!',_0x7aac13['params'][_0x1b20('0x12')]));}process[_0x1b20('0x13')](_0x7aac13[_0x1b20('0x11')][_0x1b20('0x12')],_0x1b20('0x14'));return _0x3cb78c[_0x1b20('0x8')](0xc8)['json']({'message':util[_0x1b20('0xf')]('Process\x20with\x20pid\x20%s\x20killed\x20correctly',_0x7aac13[_0x1b20('0x11')]['pid'])});})[_0x1b20('0xe')](handleError(_0x3cb78c,null,_0x1b20('0x15')));};