fe10af0d2e2e48ff5550883f654d44976750d119
[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 _0x818f=['App\x20Ready!','catch','log','Server\x20failed\x20to\x20start\x20due\x20to\x20error!','error','Server\x20failed\x20to\x20start\x20due\x20to\x20error:\x20%s','lodash','./mysqldb','./config/seedDB','./config/license','./rpc','./config/environment','app','./config/pm2','./config/pm2/config','./config/schedule','./config/schedule/chat','./config/schedule/whatsapp','./config/schedule/transcribe','./config/schedule/cloud-provider','sequelize','then','seedDB','default','listen','info','start','filter','exitCode','length','\x20processes\x20failed\x20at\x20startup:\x20','pm2_env','name','Online\x20apps:','map','join','status','online','None'];(function(_0x578718,_0x2ee959){var _0x972321=function(_0x3eba64){while(--_0x3eba64){_0x578718['push'](_0x578718['shift']());}};_0x972321(++_0x2ee959);}(_0x818f,0x1da));var _0xf818=function(_0x250347,_0x1c1403){_0x250347=_0x250347-0x0;var _0x5e5d40=_0x818f[_0x250347];return _0x5e5d40;};'use strict';var _=require(_0xf818('0x0'));var db=require(_0xf818('0x1'))['db'];var seedDb=require(_0xf818('0x2'));var checkLicense=require(_0xf818('0x3'));var rpc=require(_0xf818('0x4'));var config=require(_0xf818('0x5'));var logger=require('./config/logger')(_0xf818('0x6'));var pm2=require(_0xf818('0x7'));var pm2Config=require(_0xf818('0x8'));var schedule=require(_0xf818('0x9'));var chat=require(_0xf818('0xa'));var whatsapp=require(_0xf818('0xb'));var transcribe=require(_0xf818('0xc'));var provider=require(_0xf818('0xd'));function main(){return db[_0xf818('0xe')]['sync']()[_0xf818('0xf')](function(){if(config[_0xf818('0x10')]){return seedDb[_0xf818('0x11')]();}})['then'](function(){return checkLicense['default']();})[_0xf818('0xf')](function(){return rpc[_0xf818('0x12')]();})[_0xf818('0xf')](function(_0x3386f9){logger[_0xf818('0x13')](_0x3386f9);return chat['start']();})[_0xf818('0xf')](function(){return whatsapp[_0xf818('0x14')]();})[_0xf818('0xf')](function(){return schedule[_0xf818('0x14')]();})[_0xf818('0xf')](function(){return transcribe['start']();})['then'](function(){return provider[_0xf818('0x14')]();})[_0xf818('0xf')](function(_0x950109){logger[_0xf818('0x13')](_0x950109);return pm2['start'](pm2Config);})[_0xf818('0xf')](function(_0x3234c5){var _0xbc3568=_0x3234c5[_0xf818('0x15')](function(_0xbfdd71){return typeof _0xbfdd71['exitCode']==='number'&&_0xbfdd71[_0xf818('0x16')]>=0x0;});if(_0xbc3568['length']>0x0){throw new Error(_0xbc3568[_0xf818('0x17')]+_0xf818('0x18')+_['map'](_0xbc3568,function(_0x2bf9f3){return'\x22'+_0x2bf9f3[_0xf818('0x19')][_0xf818('0x1a')]+'\x22';}));}logger['info'](_0xf818('0x1b'),_[_0xf818('0x1c')](_[_0xf818('0x15')](_0x3234c5,{'status':'online'}),'name')[_0xf818('0x1d')]());logger[_0xf818('0x13')]('Offline\x20apps:',_[_0xf818('0x1c')](_['filter'](_0x3234c5,function(_0x1849bf){return _0x1849bf[_0xf818('0x1e')]!==_0xf818('0x1f');}),'name')[_0xf818('0x1d')]()||_0xf818('0x20'));console['log'](_0xf818('0x21'));})[_0xf818('0x22')](function(_0x1160f4){console[_0xf818('0x23')](_0xf818('0x24'),_0x1160f4);logger[_0xf818('0x25')](_0xf818('0x26'),_0x1160f4);process['exit'](0x1);});}main();