7fa34f3f190fb483a5170f11bf8f663048f9aab8
[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 _0x7b83=['./config/schedule/whatsapp','./config/schedule/transcribe','./config/schedule/cloud-provider','sync','then','default','info','start','filter','number','exitCode','length','\x20processes\x20failed\x20at\x20startup:\x20','map','name','online','Offline\x20apps:','status','join','log','App\x20Ready!','catch','Server\x20failed\x20to\x20start\x20due\x20to\x20error!','error','exit','lodash','./mysqldb','./config/seedDB','./config/environment','./config/logger','app','./config/pm2/config','./config/schedule','./config/schedule/chat'];(function(_0x2b3c9d,_0x1c8c0c){var _0x4b8037=function(_0x225327){while(--_0x225327){_0x2b3c9d['push'](_0x2b3c9d['shift']());}};_0x4b8037(++_0x1c8c0c);}(_0x7b83,0xa1));var _0x37b8=function(_0x5e03b5,_0x4820f3){_0x5e03b5=_0x5e03b5-0x0;var _0x818e7d=_0x7b83[_0x5e03b5];return _0x818e7d;};'use strict';var _=require(_0x37b8('0x0'));var db=require(_0x37b8('0x1'))['db'];var seedDb=require(_0x37b8('0x2'));var checkLicense=require('./config/license');var rpc=require('./rpc');var config=require(_0x37b8('0x3'));var logger=require(_0x37b8('0x4'))(_0x37b8('0x5'));var pm2=require('./config/pm2');var pm2Config=require(_0x37b8('0x6'));var schedule=require(_0x37b8('0x7'));var chat=require(_0x37b8('0x8'));var whatsapp=require(_0x37b8('0x9'));var transcribe=require(_0x37b8('0xa'));var provider=require(_0x37b8('0xb'));function main(){return db['sequelize'][_0x37b8('0xc')]()[_0x37b8('0xd')](function(){if(config['seedDB']){return seedDb[_0x37b8('0xe')]();}})['then'](function(){return checkLicense['default']();})['then'](function(){return rpc['listen']();})[_0x37b8('0xd')](function(_0xa1526a){logger[_0x37b8('0xf')](_0xa1526a);return chat[_0x37b8('0x10')]();})[_0x37b8('0xd')](function(){return whatsapp['start']();})[_0x37b8('0xd')](function(){return schedule['start']();})[_0x37b8('0xd')](function(){return transcribe['start']();})[_0x37b8('0xd')](function(){return provider[_0x37b8('0x10')]();})[_0x37b8('0xd')](function(_0xf737ae){logger[_0x37b8('0xf')](_0xf737ae);return pm2['start'](pm2Config);})['then'](function(_0x316229){var _0x35fe29=_0x316229[_0x37b8('0x11')](function(_0x4ab58e){return typeof _0x4ab58e['exitCode']===_0x37b8('0x12')&&_0x4ab58e[_0x37b8('0x13')]>=0x0;});if(_0x35fe29[_0x37b8('0x14')]>0x0){throw new Error(_0x35fe29[_0x37b8('0x14')]+_0x37b8('0x15')+_[_0x37b8('0x16')](_0x35fe29,function(_0x286cf3){return'\x22'+_0x286cf3['pm2_env'][_0x37b8('0x17')]+'\x22';}));}logger['info']('Online\x20apps:',_[_0x37b8('0x16')](_[_0x37b8('0x11')](_0x316229,{'status':_0x37b8('0x18')}),_0x37b8('0x17'))['join']());logger[_0x37b8('0xf')](_0x37b8('0x19'),_[_0x37b8('0x16')](_[_0x37b8('0x11')](_0x316229,function(_0x497623){return _0x497623[_0x37b8('0x1a')]!==_0x37b8('0x18');}),_0x37b8('0x17'))[_0x37b8('0x1b')]()||'None');console[_0x37b8('0x1c')](_0x37b8('0x1d'));})[_0x37b8('0x1e')](function(_0x1cf84a){console[_0x37b8('0x1c')](_0x37b8('0x1f'),_0x1cf84a);logger[_0x37b8('0x20')]('Server\x20failed\x20to\x20start\x20due\x20to\x20error:\x20%s',_0x1cf84a);process[_0x37b8('0x21')](0x1);});}main();