Built motion from commit 8c034dcd.|2.6.31
[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 _0x1354=['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','./config/pm2','./config/pm2/config','./config/schedule','./config/schedule/whatsapp','./config/schedule/transcribe','sequelize','sync','then','default','listen','info','start','filter','number','exitCode','\x20processes\x20failed\x20at\x20startup:\x20','map','online','name','join','Offline\x20apps:','status','None','log'];(function(_0x26aee5,_0x3d18ea){var _0x5ab716=function(_0x3cce5d){while(--_0x3cce5d){_0x26aee5['push'](_0x26aee5['shift']());}};_0x5ab716(++_0x3d18ea);}(_0x1354,0x95));var _0x4135=function(_0x3c62ab,_0x33f23d){_0x3c62ab=_0x3c62ab-0x0;var _0x536970=_0x1354[_0x3c62ab];return _0x536970;};'use strict';var _=require(_0x4135('0x0'));var db=require(_0x4135('0x1'))['db'];var seedDb=require(_0x4135('0x2'));var checkLicense=require(_0x4135('0x3'));var rpc=require(_0x4135('0x4'));var config=require(_0x4135('0x5'));var logger=require(_0x4135('0x6'))('app');var pm2=require(_0x4135('0x7'));var pm2Config=require(_0x4135('0x8'));var schedule=require(_0x4135('0x9'));var chat=require('./config/schedule/chat');var whatsapp=require(_0x4135('0xa'));var transcribe=require(_0x4135('0xb'));var provider=require('./config/schedule/cloud-provider');function main(){return db[_0x4135('0xc')][_0x4135('0xd')]()[_0x4135('0xe')](function(){if(config['seedDB']){return seedDb[_0x4135('0xf')]();}})['then'](function(){return checkLicense[_0x4135('0xf')]();})[_0x4135('0xe')](function(){return rpc[_0x4135('0x10')]();})[_0x4135('0xe')](function(_0x5dd78a){logger[_0x4135('0x11')](_0x5dd78a);return chat['start']();})['then'](function(){return whatsapp[_0x4135('0x12')]();})[_0x4135('0xe')](function(){return schedule[_0x4135('0x12')]();})['then'](function(){return transcribe[_0x4135('0x12')]();})[_0x4135('0xe')](function(){return provider[_0x4135('0x12')]();})[_0x4135('0xe')](function(_0x3731e8){logger[_0x4135('0x11')](_0x3731e8);return pm2['start'](pm2Config);})['then'](function(_0x249c86){var _0x3c90cf=_0x249c86[_0x4135('0x13')](function(_0x17179a){return typeof _0x17179a['exitCode']===_0x4135('0x14')&&_0x17179a[_0x4135('0x15')]>=0x0;});if(_0x3c90cf['length']>0x0){throw new Error(_0x3c90cf['length']+_0x4135('0x16')+_['map'](_0x3c90cf,function(_0x2f2600){return'\x22'+_0x2f2600['pm2_env']['name']+'\x22';}));}logger['info']('Online\x20apps:',_[_0x4135('0x17')](_['filter'](_0x249c86,{'status':_0x4135('0x18')}),_0x4135('0x19'))[_0x4135('0x1a')]());logger['info'](_0x4135('0x1b'),_[_0x4135('0x17')](_[_0x4135('0x13')](_0x249c86,function(_0x485395){return _0x485395[_0x4135('0x1c')]!=='online';}),_0x4135('0x19'))[_0x4135('0x1a')]()||_0x4135('0x1d'));console[_0x4135('0x1e')]('App\x20Ready!');})[_0x4135('0x1f')](function(_0x126527){console[_0x4135('0x1e')](_0x4135('0x20'),_0x126527);logger[_0x4135('0x21')](_0x4135('0x22'),_0x126527);process[_0x4135('0x23')](0x1);});}main();