7e1c316e8623d5fa3f75f3c4554f507c8068b651
[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 _0xfdb3=['./config/pm2','./config/pm2/config','./config/schedule','./config/schedule/chat','./config/schedule/whatsapp','./config/schedule/cloud-provider','sequelize','sync','seedDB','then','default','listen','start','info','filter','exitCode','number','\x20processes\x20failed\x20at\x20startup:\x20','map','pm2_env','name','Online\x20apps:','online','Offline\x20apps:','join','log','Server\x20failed\x20to\x20start\x20due\x20to\x20error!','error','Server\x20failed\x20to\x20start\x20due\x20to\x20error:\x20%s','exit','lodash','./mysqldb','./config/license','./config/logger'];(function(_0x1aeda2,_0x1217eb){var _0x32dc6d=function(_0x34a460){while(--_0x34a460){_0x1aeda2['push'](_0x1aeda2['shift']());}};_0x32dc6d(++_0x1217eb);}(_0xfdb3,0x10c));var _0x3fdb=function(_0x569e00,_0x4942ee){_0x569e00=_0x569e00-0x0;var _0x3367fb=_0xfdb3[_0x569e00];return _0x3367fb;};'use strict';var _=require(_0x3fdb('0x0'));var db=require(_0x3fdb('0x1'))['db'];var seedDb=require('./config/seedDB');var checkLicense=require(_0x3fdb('0x2'));var rpc=require('./rpc');var config=require('./config/environment');var logger=require(_0x3fdb('0x3'))('app');var pm2=require(_0x3fdb('0x4'));var pm2Config=require(_0x3fdb('0x5'));var schedule=require(_0x3fdb('0x6'));var chat=require(_0x3fdb('0x7'));var whatsapp=require(_0x3fdb('0x8'));var transcribe=require('./config/schedule/transcribe');var provider=require(_0x3fdb('0x9'));function main(){return db[_0x3fdb('0xa')][_0x3fdb('0xb')]()['then'](function(){if(config[_0x3fdb('0xc')]){return seedDb['default']();}})[_0x3fdb('0xd')](function(){return checkLicense[_0x3fdb('0xe')]();})[_0x3fdb('0xd')](function(){return rpc[_0x3fdb('0xf')]();})[_0x3fdb('0xd')](function(_0x5bbb9f){logger['info'](_0x5bbb9f);return chat['start']();})['then'](function(){return whatsapp[_0x3fdb('0x10')]();})[_0x3fdb('0xd')](function(){return schedule[_0x3fdb('0x10')]();})[_0x3fdb('0xd')](function(){return transcribe[_0x3fdb('0x10')]();})[_0x3fdb('0xd')](function(){return provider[_0x3fdb('0x10')]();})[_0x3fdb('0xd')](function(_0x1a6dbc){logger[_0x3fdb('0x11')](_0x1a6dbc);return pm2['start'](pm2Config);})[_0x3fdb('0xd')](function(_0x1a5dd8){var _0x4cbc07=_0x1a5dd8[_0x3fdb('0x12')](function(_0x31cd0e){return typeof _0x31cd0e[_0x3fdb('0x13')]===_0x3fdb('0x14')&&_0x31cd0e['exitCode']>=0x0;});if(_0x4cbc07['length']>0x0){throw new Error(_0x4cbc07['length']+_0x3fdb('0x15')+_[_0x3fdb('0x16')](_0x4cbc07,function(_0x11d57d){return'\x22'+_0x11d57d[_0x3fdb('0x17')][_0x3fdb('0x18')]+'\x22';}));}logger['info'](_0x3fdb('0x19'),_[_0x3fdb('0x16')](_[_0x3fdb('0x12')](_0x1a5dd8,{'status':_0x3fdb('0x1a')}),_0x3fdb('0x18'))['join']());logger[_0x3fdb('0x11')](_0x3fdb('0x1b'),_[_0x3fdb('0x16')](_[_0x3fdb('0x12')](_0x1a5dd8,function(_0x403f48){return _0x403f48['status']!==_0x3fdb('0x1a');}),'name')[_0x3fdb('0x1c')]()||'None');console['log']('App\x20Ready!');})['catch'](function(_0x171837){console[_0x3fdb('0x1d')](_0x3fdb('0x1e'),_0x171837);logger[_0x3fdb('0x1f')](_0x3fdb('0x20'),_0x171837);process[_0x3fdb('0x21')](0x1);});}main();