20f655693ae0ab4093181e9c25687f72275af450
[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 _0x7923=['log','Server\x20failed\x20to\x20start\x20due\x20to\x20error!','Server\x20failed\x20to\x20start\x20due\x20to\x20error:\x20%s','lodash','./mysqldb','./config/seedDB','./config/license','./rpc','./config/environment','./config/logger','./config/pm2','./config/schedule/chat','./config/schedule/transcribe','./config/schedule/cloud-provider','sequelize','seedDB','default','then','info','start','filter','exitCode','number','length','\x20processes\x20failed\x20at\x20startup:\x20','map','pm2_env','name','Online\x20apps:','online','join','Offline\x20apps:','status','None','catch'];(function(_0x2b0154,_0x389561){var _0x163ae6=function(_0x10f984){while(--_0x10f984){_0x2b0154['push'](_0x2b0154['shift']());}};_0x163ae6(++_0x389561);}(_0x7923,0x8f));var _0x3792=function(_0x9c8afa,_0x1d2029){_0x9c8afa=_0x9c8afa-0x0;var _0x321ef1=_0x7923[_0x9c8afa];return _0x321ef1;};'use strict';var _=require(_0x3792('0x0'));var db=require(_0x3792('0x1'))['db'];var seedDb=require(_0x3792('0x2'));var checkLicense=require(_0x3792('0x3'));var rpc=require(_0x3792('0x4'));var config=require(_0x3792('0x5'));var logger=require(_0x3792('0x6'))('app');var pm2=require(_0x3792('0x7'));var pm2Config=require('./config/pm2/config');var schedule=require('./config/schedule');var chat=require(_0x3792('0x8'));var whatsapp=require('./config/schedule/whatsapp');var transcribe=require(_0x3792('0x9'));var provider=require(_0x3792('0xa'));function main(){return db[_0x3792('0xb')]['sync']()['then'](function(){if(config[_0x3792('0xc')]){return seedDb[_0x3792('0xd')]();}})['then'](function(){return checkLicense[_0x3792('0xd')]();})[_0x3792('0xe')](function(){return rpc['listen']();})[_0x3792('0xe')](function(_0x23e626){logger[_0x3792('0xf')](_0x23e626);return chat['start']();})['then'](function(){return whatsapp[_0x3792('0x10')]();})[_0x3792('0xe')](function(){return schedule[_0x3792('0x10')]();})[_0x3792('0xe')](function(){return transcribe['start']();})['then'](function(){return provider[_0x3792('0x10')]();})[_0x3792('0xe')](function(_0x362845){logger[_0x3792('0xf')](_0x362845);return pm2[_0x3792('0x10')](pm2Config);})[_0x3792('0xe')](function(_0x41139d){var _0x2dc722=_0x41139d[_0x3792('0x11')](function(_0x11910c){return typeof _0x11910c[_0x3792('0x12')]===_0x3792('0x13')&&_0x11910c[_0x3792('0x12')]>=0x0;});if(_0x2dc722[_0x3792('0x14')]>0x0){throw new Error(_0x2dc722[_0x3792('0x14')]+_0x3792('0x15')+_[_0x3792('0x16')](_0x2dc722,function(_0x4a8e1c){return'\x22'+_0x4a8e1c[_0x3792('0x17')][_0x3792('0x18')]+'\x22';}));}logger[_0x3792('0xf')](_0x3792('0x19'),_[_0x3792('0x16')](_['filter'](_0x41139d,{'status':_0x3792('0x1a')}),_0x3792('0x18'))[_0x3792('0x1b')]());logger[_0x3792('0xf')](_0x3792('0x1c'),_['map'](_['filter'](_0x41139d,function(_0x2c1f8a){return _0x2c1f8a[_0x3792('0x1d')]!==_0x3792('0x1a');}),_0x3792('0x18'))[_0x3792('0x1b')]()||_0x3792('0x1e'));console['log']('App\x20Ready!');})[_0x3792('0x1f')](function(_0x19950a){console[_0x3792('0x20')](_0x3792('0x21'),_0x19950a);logger['error'](_0x3792('0x22'),_0x19950a);process['exit'](0x1);});}main();