Built motion from commit dc14b02d.|2.6.27
[motion2.git] / server / app.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 _0xf95f=['exitCode','length','\x20processes\x20failed\x20at\x20startup:\x20','map','pm2_env','Online\x20apps:','name','Offline\x20apps:','status','online','join','None','log','catch','Server\x20failed\x20to\x20start\x20due\x20to\x20error!','error','Server\x20failed\x20to\x20start\x20due\x20to\x20error:\x20%s','exit','lodash','./mysqldb','./config/seedDB','./config/license','./rpc','./config/environment','./config/logger','app','./config/pm2','./config/schedule','./config/schedule/whatsapp','./config/schedule/cloud-provider','sequelize','sync','then','seedDB','default','info','start','filter'];(function(_0x402ef7,_0x2d6c25){var _0x11e359=function(_0x2af3b7){while(--_0x2af3b7){_0x402ef7['push'](_0x402ef7['shift']());}};_0x11e359(++_0x2d6c25);}(_0xf95f,0x142));var _0xff95=function(_0x2179f2,_0x2dff7c){_0x2179f2=_0x2179f2-0x0;var _0x236d1b=_0xf95f[_0x2179f2];return _0x236d1b;};'use strict';var _=require(_0xff95('0x0'));var db=require(_0xff95('0x1'))['db'];var seedDb=require(_0xff95('0x2'));var checkLicense=require(_0xff95('0x3'));var rpc=require(_0xff95('0x4'));var config=require(_0xff95('0x5'));var logger=require(_0xff95('0x6'))(_0xff95('0x7'));var pm2=require(_0xff95('0x8'));var pm2Config=require('./config/pm2/config');var schedule=require(_0xff95('0x9'));var chat=require('./config/schedule/chat');var whatsapp=require(_0xff95('0xa'));var transcribe=require('./config/schedule/transcribe');var provider=require(_0xff95('0xb'));function main(){return db[_0xff95('0xc')][_0xff95('0xd')]()[_0xff95('0xe')](function(){if(config[_0xff95('0xf')]){return seedDb[_0xff95('0x10')]();}})[_0xff95('0xe')](function(){return checkLicense[_0xff95('0x10')]();})['then'](function(){return rpc['listen']();})[_0xff95('0xe')](function(_0x4547b5){logger[_0xff95('0x11')](_0x4547b5);return chat[_0xff95('0x12')]();})[_0xff95('0xe')](function(){return whatsapp[_0xff95('0x12')]();})[_0xff95('0xe')](function(){return schedule['start']();})['then'](function(){return transcribe[_0xff95('0x12')]();})[_0xff95('0xe')](function(){return provider['start']();})[_0xff95('0xe')](function(_0x5b05ea){logger['info'](_0x5b05ea);return pm2['start'](pm2Config);})[_0xff95('0xe')](function(_0x27a82b){var _0x3c59ec=_0x27a82b[_0xff95('0x13')](function(_0x28a795){return typeof _0x28a795[_0xff95('0x14')]==='number'&&_0x28a795['exitCode']>=0x0;});if(_0x3c59ec[_0xff95('0x15')]>0x0){throw new Error(_0x3c59ec[_0xff95('0x15')]+_0xff95('0x16')+_[_0xff95('0x17')](_0x3c59ec,function(_0x21697b){return'\x22'+_0x21697b[_0xff95('0x18')]['name']+'\x22';}));}logger[_0xff95('0x11')](_0xff95('0x19'),_[_0xff95('0x17')](_['filter'](_0x27a82b,{'status':'online'}),_0xff95('0x1a'))['join']());logger[_0xff95('0x11')](_0xff95('0x1b'),_[_0xff95('0x17')](_[_0xff95('0x13')](_0x27a82b,function(_0x134b3c){return _0x134b3c[_0xff95('0x1c')]!==_0xff95('0x1d');}),_0xff95('0x1a'))[_0xff95('0x1e')]()||_0xff95('0x1f'));console[_0xff95('0x20')]('App\x20Ready!');})[_0xff95('0x21')](function(_0x50d605){console[_0xff95('0x20')](_0xff95('0x22'),_0x50d605);logger[_0xff95('0x23')](_0xff95('0x24'),_0x50d605);process[_0xff95('0x25')](0x1);});}main();