43bcf01480bd880a62cf9bc3f92ccbae3f6e592c
[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 _0x826b=['indexOf','pid','kill','SIGINT','killProcess','systeminformation','child_process','exec','../../config/logger','api','<%-\x20name\x20%>,\x20%s,\x20%s,\x20%s','inspect','status','send','index','getAllData','then','catch','json','components/import/cm','format','ps\x20-p\x20%s\x20-ww\x20-o\x20args','params','split','length'];(function(_0x23b0aa,_0x5967c1){var _0x299166=function(_0x6f8203){while(--_0x6f8203){_0x23b0aa['push'](_0x23b0aa['shift']());}};_0x299166(++_0x5967c1);}(_0x826b,0x131));var _0xb826=function(_0x3e88bb,_0x13e981){_0x3e88bb=_0x3e88bb-0x0;var _0x17bbfa=_0x826b[_0x3e88bb];return _0x17bbfa;};'use strict';var info=require(_0xb826('0x0'));var exec=require(_0xb826('0x1'))[_0xb826('0x2')];var logger=require(_0xb826('0x3'))(_0xb826('0x4'));var util=require('util');var BPromise=require('bluebird');var _=require('lodash');function handleError(_0x48b91c,_0x24bdb1,_0x5c806c){_0x24bdb1=_0x24bdb1||0x1f4;return function(_0x44bacf){logger['error'](_0xb826('0x5'),_0x5c806c,_0x24bdb1,util[_0xb826('0x6')](_0x44bacf,{'showHidden':![],'depth':null}));delete _0x44bacf['name'];_0x48b91c[_0xb826('0x7')](_0x24bdb1)[_0xb826('0x8')](_0x44bacf);};}exports[_0xb826('0x9')]=function(_0x324170,_0x21c16b){return info[_0xb826('0xa')]()[_0xb826('0xb')](function(_0x2cd8d8){return _0x21c16b[_0xb826('0x7')](0xc8)['json'](_0x2cd8d8);})[_0xb826('0xc')](function(_0x4d8824){return _0x21c16b[_0xb826('0x7')](0x1f4)[_0xb826('0xd')](_0x4d8824);});};exports['killProcess']=function(_0x5e52e3,_0x376e79){var _0xb72cd2=[_0xb826('0xe')];return new BPromise(function(_0x11ad18,_0x4b4376){return exec(util[_0xb826('0xf')](_0xb826('0x10'),_0x5e52e3[_0xb826('0x11')]['pid']),function(_0xaf7fd9,_0x271ffe,_0x2db3af){if(_0xaf7fd9){return _0x4b4376(_0xaf7fd9);}return _0x11ad18(_0x271ffe);});})['then'](function(_0x1c26a5){var _0x1374a3=![];var _0x2eefff=_0x1c26a5[_0xb826('0x12')](/\n/);for(var _0x20d884=0x0,_0x5af946=_0xb72cd2[_0xb826('0x13')];_0x20d884<_0x5af946,_0x1374a3===![];_0x20d884+=0x1){if(_0x1c26a5[_0xb826('0x14')](_0xb72cd2[_0x20d884])>=0x0){_0x1374a3=!![];}}if(!_0x1374a3){throw new Error(util[_0xb826('0xf')]('Process\x20with\x20pid\x20%s\x20not\x20found!',_0x5e52e3['params'][_0xb826('0x15')]));}process[_0xb826('0x16')](_0x5e52e3['params'][_0xb826('0x15')],_0xb826('0x17'));return _0x376e79[_0xb826('0x7')](0xc8)['json']({'message':util[_0xb826('0xf')]('Process\x20with\x20pid\x20%s\x20killed\x20correctly',_0x5e52e3['params'][_0xb826('0x15')])});})['catch'](handleError(_0x376e79,null,_0xb826('0x18')));};