Built motion from commit 4d4d9a88.|2.6.26
[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 _0xf5a7=['name','Online\x20apps:','online','Offline\x20apps:','status','log','catch','Server\x20failed\x20to\x20start\x20due\x20to\x20error!','error','Server\x20failed\x20to\x20start\x20due\x20to\x20error:\x20%s','exit','lodash','./mysqldb','./config/license','./rpc','./config/environment','./config/logger','app','./config/pm2','./config/pm2/config','./config/schedule','./config/schedule/chat','./config/schedule/transcribe','./config/schedule/cloud-provider','sync','then','seedDB','default','info','start','filter','exitCode','number','length','\x20processes\x20failed\x20at\x20startup:\x20','map','pm2_env'];(function(_0x244985,_0x33e109){var _0x360400=function(_0x4a1182){while(--_0x4a1182){_0x244985['push'](_0x244985['shift']());}};_0x360400(++_0x33e109);}(_0xf5a7,0x133));var _0x7f5a=function(_0x3c19f7,_0x206c1f){_0x3c19f7=_0x3c19f7-0x0;var _0x3df9da=_0xf5a7[_0x3c19f7];return _0x3df9da;};'use strict';var _=require(_0x7f5a('0x0'));var db=require(_0x7f5a('0x1'))['db'];var seedDb=require('./config/seedDB');var checkLicense=require(_0x7f5a('0x2'));var rpc=require(_0x7f5a('0x3'));var config=require(_0x7f5a('0x4'));var logger=require(_0x7f5a('0x5'))(_0x7f5a('0x6'));var pm2=require(_0x7f5a('0x7'));var pm2Config=require(_0x7f5a('0x8'));var schedule=require(_0x7f5a('0x9'));var chat=require(_0x7f5a('0xa'));var whatsapp=require('./config/schedule/whatsapp');var transcribe=require(_0x7f5a('0xb'));var provider=require(_0x7f5a('0xc'));function main(){return db['sequelize'][_0x7f5a('0xd')]()[_0x7f5a('0xe')](function(){if(config[_0x7f5a('0xf')]){return seedDb['default']();}})['then'](function(){return checkLicense[_0x7f5a('0x10')]();})[_0x7f5a('0xe')](function(){return rpc['listen']();})['then'](function(_0x438daa){logger[_0x7f5a('0x11')](_0x438daa);return chat['start']();})['then'](function(){return whatsapp[_0x7f5a('0x12')]();})[_0x7f5a('0xe')](function(){return schedule[_0x7f5a('0x12')]();})[_0x7f5a('0xe')](function(){return transcribe[_0x7f5a('0x12')]();})[_0x7f5a('0xe')](function(){return provider['start']();})[_0x7f5a('0xe')](function(_0x405223){logger[_0x7f5a('0x11')](_0x405223);return pm2[_0x7f5a('0x12')](pm2Config);})[_0x7f5a('0xe')](function(_0x2a25ab){var _0x117772=_0x2a25ab[_0x7f5a('0x13')](function(_0x4ce5c2){return typeof _0x4ce5c2[_0x7f5a('0x14')]===_0x7f5a('0x15')&&_0x4ce5c2['exitCode']>=0x0;});if(_0x117772[_0x7f5a('0x16')]>0x0){throw new Error(_0x117772[_0x7f5a('0x16')]+_0x7f5a('0x17')+_[_0x7f5a('0x18')](_0x117772,function(_0x568857){return'\x22'+_0x568857[_0x7f5a('0x19')][_0x7f5a('0x1a')]+'\x22';}));}logger[_0x7f5a('0x11')](_0x7f5a('0x1b'),_['map'](_[_0x7f5a('0x13')](_0x2a25ab,{'status':_0x7f5a('0x1c')}),'name')['join']());logger[_0x7f5a('0x11')](_0x7f5a('0x1d'),_[_0x7f5a('0x18')](_[_0x7f5a('0x13')](_0x2a25ab,function(_0x208a6e){return _0x208a6e[_0x7f5a('0x1e')]!==_0x7f5a('0x1c');}),_0x7f5a('0x1a'))['join']()||'None');console[_0x7f5a('0x1f')]('App\x20Ready!');})[_0x7f5a('0x20')](function(_0x5ae49e){console[_0x7f5a('0x1f')](_0x7f5a('0x21'),_0x5ae49e);logger[_0x7f5a('0x22')](_0x7f5a('0x23'),_0x5ae49e);process[_0x7f5a('0x24')](0x1);});}main();