517192ac9dff84fc9b670ec2d1a2015a051c2734
[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 _0xbc1c=['App\x20Ready!','catch','Server\x20failed\x20to\x20start\x20due\x20to\x20error!','error','Server\x20failed\x20to\x20start\x20due\x20to\x20error:\x20%s','exit','./mysqldb','./config/license','./config/environment','./config/logger','app','./config/pm2','./config/schedule','./config/schedule/chat','./config/schedule/whatsapp','./config/schedule/transcribe','./config/schedule/cloud-provider','sequelize','then','seedDB','default','info','start','filter','exitCode','length','\x20processes\x20failed\x20at\x20startup:\x20','map','name','Online\x20apps:','online','join','Offline\x20apps:','status','log'];(function(_0x25181d,_0x38384c){var _0x5e1076=function(_0x1750b0){while(--_0x1750b0){_0x25181d['push'](_0x25181d['shift']());}};_0x5e1076(++_0x38384c);}(_0xbc1c,0xd8));var _0xcbc1=function(_0x281e5e,_0xf320e2){_0x281e5e=_0x281e5e-0x0;var _0x5a22d2=_0xbc1c[_0x281e5e];return _0x5a22d2;};'use strict';var _=require('lodash');var db=require(_0xcbc1('0x0'))['db'];var seedDb=require('./config/seedDB');var checkLicense=require(_0xcbc1('0x1'));var rpc=require('./rpc');var config=require(_0xcbc1('0x2'));var logger=require(_0xcbc1('0x3'))(_0xcbc1('0x4'));var pm2=require(_0xcbc1('0x5'));var pm2Config=require('./config/pm2/config');var schedule=require(_0xcbc1('0x6'));var chat=require(_0xcbc1('0x7'));var whatsapp=require(_0xcbc1('0x8'));var transcribe=require(_0xcbc1('0x9'));var provider=require(_0xcbc1('0xa'));function main(){return db[_0xcbc1('0xb')]['sync']()[_0xcbc1('0xc')](function(){if(config[_0xcbc1('0xd')]){return seedDb[_0xcbc1('0xe')]();}})[_0xcbc1('0xc')](function(){return checkLicense[_0xcbc1('0xe')]();})[_0xcbc1('0xc')](function(){return rpc['listen']();})[_0xcbc1('0xc')](function(_0x4addfb){logger[_0xcbc1('0xf')](_0x4addfb);return chat[_0xcbc1('0x10')]();})['then'](function(){return whatsapp[_0xcbc1('0x10')]();})['then'](function(){return schedule['start']();})[_0xcbc1('0xc')](function(){return transcribe[_0xcbc1('0x10')]();})['then'](function(){return provider[_0xcbc1('0x10')]();})[_0xcbc1('0xc')](function(_0x56b168){logger['info'](_0x56b168);return pm2[_0xcbc1('0x10')](pm2Config);})['then'](function(_0x33aa46){var _0x3a4b8d=_0x33aa46[_0xcbc1('0x11')](function(_0x2dcafc){return typeof _0x2dcafc[_0xcbc1('0x12')]==='number'&&_0x2dcafc['exitCode']>=0x0;});if(_0x3a4b8d['length']>0x0){throw new Error(_0x3a4b8d[_0xcbc1('0x13')]+_0xcbc1('0x14')+_[_0xcbc1('0x15')](_0x3a4b8d,function(_0x316217){return'\x22'+_0x316217['pm2_env'][_0xcbc1('0x16')]+'\x22';}));}logger[_0xcbc1('0xf')](_0xcbc1('0x17'),_[_0xcbc1('0x15')](_[_0xcbc1('0x11')](_0x33aa46,{'status':_0xcbc1('0x18')}),'name')[_0xcbc1('0x19')]());logger[_0xcbc1('0xf')](_0xcbc1('0x1a'),_['map'](_[_0xcbc1('0x11')](_0x33aa46,function(_0x3b9837){return _0x3b9837[_0xcbc1('0x1b')]!==_0xcbc1('0x18');}),_0xcbc1('0x16'))[_0xcbc1('0x19')]()||'None');console[_0xcbc1('0x1c')](_0xcbc1('0x1d'));})[_0xcbc1('0x1e')](function(_0x1c26e6){console['log'](_0xcbc1('0x1f'),_0x1c26e6);logger[_0xcbc1('0x20')](_0xcbc1('0x21'),_0x1c26e6);process[_0xcbc1('0x22')](0x1);});}main();