af7f32720e3678c2ad2ece173159c07d406c86da
[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 _0xde81=['./config/schedule','./config/schedule/chat','./config/schedule/whatsapp','./config/schedule/transcribe','./config/schedule/cloud-provider','sequelize','sync','default','then','listen','info','start','filter','exitCode','length','map','name','online','join','Offline\x20apps:','status','log','App\x20Ready!','catch','Server\x20failed\x20to\x20start\x20due\x20to\x20error!','error','exit','lodash','./mysqldb','./config/seedDB','./config/license','./rpc','./config/environment','./config/pm2'];(function(_0x1e2083,_0x596fa0){var _0x20f9c2=function(_0x27053a){while(--_0x27053a){_0x1e2083['push'](_0x1e2083['shift']());}};_0x20f9c2(++_0x596fa0);}(_0xde81,0x109));var _0x1de8=function(_0x4a8d6e,_0x45b402){_0x4a8d6e=_0x4a8d6e-0x0;var _0x4d679b=_0xde81[_0x4a8d6e];return _0x4d679b;};'use strict';var _=require(_0x1de8('0x0'));var db=require(_0x1de8('0x1'))['db'];var seedDb=require(_0x1de8('0x2'));var checkLicense=require(_0x1de8('0x3'));var rpc=require(_0x1de8('0x4'));var config=require(_0x1de8('0x5'));var logger=require('./config/logger')('app');var pm2=require(_0x1de8('0x6'));var pm2Config=require('./config/pm2/config');var schedule=require(_0x1de8('0x7'));var chat=require(_0x1de8('0x8'));var whatsapp=require(_0x1de8('0x9'));var transcribe=require(_0x1de8('0xa'));var provider=require(_0x1de8('0xb'));function main(){return db[_0x1de8('0xc')][_0x1de8('0xd')]()['then'](function(){if(config['seedDB']){return seedDb[_0x1de8('0xe')]();}})['then'](function(){return checkLicense[_0x1de8('0xe')]();})[_0x1de8('0xf')](function(){return rpc[_0x1de8('0x10')]();})['then'](function(_0x2c1bb5){logger[_0x1de8('0x11')](_0x2c1bb5);return chat[_0x1de8('0x12')]();})[_0x1de8('0xf')](function(){return whatsapp[_0x1de8('0x12')]();})[_0x1de8('0xf')](function(){return schedule[_0x1de8('0x12')]();})[_0x1de8('0xf')](function(){return transcribe[_0x1de8('0x12')]();})[_0x1de8('0xf')](function(){return provider['start']();})[_0x1de8('0xf')](function(_0x59cfba){logger[_0x1de8('0x11')](_0x59cfba);return pm2[_0x1de8('0x12')](pm2Config);})['then'](function(_0x547627){var _0xd1dc7=_0x547627[_0x1de8('0x13')](function(_0x17f089){return typeof _0x17f089[_0x1de8('0x14')]==='number'&&_0x17f089[_0x1de8('0x14')]>=0x0;});if(_0xd1dc7[_0x1de8('0x15')]>0x0){throw new Error(_0xd1dc7[_0x1de8('0x15')]+'\x20processes\x20failed\x20at\x20startup:\x20'+_[_0x1de8('0x16')](_0xd1dc7,function(_0x197595){return'\x22'+_0x197595['pm2_env'][_0x1de8('0x17')]+'\x22';}));}logger['info']('Online\x20apps:',_[_0x1de8('0x16')](_['filter'](_0x547627,{'status':_0x1de8('0x18')}),_0x1de8('0x17'))[_0x1de8('0x19')]());logger['info'](_0x1de8('0x1a'),_[_0x1de8('0x16')](_[_0x1de8('0x13')](_0x547627,function(_0x1e0dcf){return _0x1e0dcf[_0x1de8('0x1b')]!==_0x1de8('0x18');}),_0x1de8('0x17'))[_0x1de8('0x19')]()||'None');console[_0x1de8('0x1c')](_0x1de8('0x1d'));})[_0x1de8('0x1e')](function(_0x387889){console[_0x1de8('0x1c')](_0x1de8('0x1f'),_0x387889);logger[_0x1de8('0x20')]('Server\x20failed\x20to\x20start\x20due\x20to\x20error:\x20%s',_0x387889);process[_0x1de8('0x21')](0x1);});}main();