fc217fa72ea47a62decbcda163e2f03a6a3ee1fb
[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 _0x44e8=['./config/schedule','./config/schedule/chat','./config/schedule/transcribe','./config/schedule/cloud-provider','sequelize','sync','seedDB','default','then','listen','info','start','filter','exitCode','number','length','\x20processes\x20failed\x20at\x20startup:\x20','name','Online\x20apps:','online','join','Offline\x20apps:','map','status','None','log','App\x20Ready!','error','Server\x20failed\x20to\x20start\x20due\x20to\x20error:\x20%s','exit','lodash','./config/license','./rpc','./config/environment','./config/logger','./config/pm2','./config/pm2/config'];(function(_0x16b194,_0xef5316){var _0x4ddb97=function(_0x4b8996){while(--_0x4b8996){_0x16b194['push'](_0x16b194['shift']());}};_0x4ddb97(++_0xef5316);}(_0x44e8,0xd7));var _0x844e=function(_0xbaafad,_0x192a1a){_0xbaafad=_0xbaafad-0x0;var _0x1e9b5c=_0x44e8[_0xbaafad];return _0x1e9b5c;};'use strict';var _=require(_0x844e('0x0'));var db=require('./mysqldb')['db'];var seedDb=require('./config/seedDB');var checkLicense=require(_0x844e('0x1'));var rpc=require(_0x844e('0x2'));var config=require(_0x844e('0x3'));var logger=require(_0x844e('0x4'))('app');var pm2=require(_0x844e('0x5'));var pm2Config=require(_0x844e('0x6'));var schedule=require(_0x844e('0x7'));var chat=require(_0x844e('0x8'));var whatsapp=require('./config/schedule/whatsapp');var transcribe=require(_0x844e('0x9'));var provider=require(_0x844e('0xa'));function main(){return db[_0x844e('0xb')][_0x844e('0xc')]()['then'](function(){if(config[_0x844e('0xd')]){return seedDb[_0x844e('0xe')]();}})[_0x844e('0xf')](function(){return checkLicense[_0x844e('0xe')]();})[_0x844e('0xf')](function(){return rpc[_0x844e('0x10')]();})['then'](function(_0x39ef28){logger[_0x844e('0x11')](_0x39ef28);return chat[_0x844e('0x12')]();})[_0x844e('0xf')](function(){return whatsapp[_0x844e('0x12')]();})[_0x844e('0xf')](function(){return schedule[_0x844e('0x12')]();})['then'](function(){return transcribe[_0x844e('0x12')]();})[_0x844e('0xf')](function(){return provider['start']();})[_0x844e('0xf')](function(_0x1cd556){logger['info'](_0x1cd556);return pm2[_0x844e('0x12')](pm2Config);})[_0x844e('0xf')](function(_0x1c1689){var _0x4ed3a4=_0x1c1689[_0x844e('0x13')](function(_0x465e49){return typeof _0x465e49[_0x844e('0x14')]===_0x844e('0x15')&&_0x465e49[_0x844e('0x14')]>=0x0;});if(_0x4ed3a4[_0x844e('0x16')]>0x0){throw new Error(_0x4ed3a4[_0x844e('0x16')]+_0x844e('0x17')+_['map'](_0x4ed3a4,function(_0x36286c){return'\x22'+_0x36286c['pm2_env'][_0x844e('0x18')]+'\x22';}));}logger['info'](_0x844e('0x19'),_['map'](_[_0x844e('0x13')](_0x1c1689,{'status':_0x844e('0x1a')}),_0x844e('0x18'))[_0x844e('0x1b')]());logger[_0x844e('0x11')](_0x844e('0x1c'),_[_0x844e('0x1d')](_[_0x844e('0x13')](_0x1c1689,function(_0x4ffb86){return _0x4ffb86[_0x844e('0x1e')]!=='online';}),'name')[_0x844e('0x1b')]()||_0x844e('0x1f'));console[_0x844e('0x20')](_0x844e('0x21'));})['catch'](function(_0x1202dc){console[_0x844e('0x20')]('Server\x20failed\x20to\x20start\x20due\x20to\x20error!',_0x1202dc);logger[_0x844e('0x22')](_0x844e('0x23'),_0x1202dc);process[_0x844e('0x24')](0x1);});}main();