Built motion from commit 25580385.|2.6.2
[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 _0x4a25=['./config/schedule/chat','./config/schedule/whatsapp','./config/schedule/transcribe','sequelize','sync','then','listen','info','start','filter','exitCode','number','length','\x20processes\x20failed\x20at\x20startup:\x20','map','name','join','Offline\x20apps:','status','None','App\x20Ready!','catch','log','Server\x20failed\x20to\x20start\x20due\x20to\x20error!','Server\x20failed\x20to\x20start\x20due\x20to\x20error:\x20%s','exit','lodash','./config/seedDB','./rpc','./config/environment','./config/logger','app','./config/pm2/config','./config/schedule'];(function(_0xffa198,_0x5a8940){var _0x1e4b50=function(_0x1f1c43){while(--_0x1f1c43){_0xffa198['push'](_0xffa198['shift']());}};_0x1e4b50(++_0x5a8940);}(_0x4a25,0x1d4));var _0x54a2=function(_0x1635fe,_0x5f1d9f){_0x1635fe=_0x1635fe-0x0;var _0x3c512a=_0x4a25[_0x1635fe];return _0x3c512a;};'use strict';var _=require(_0x54a2('0x0'));var db=require('./mysqldb')['db'];var seedDb=require(_0x54a2('0x1'));var checkLicense=require('./config/license');var rpc=require(_0x54a2('0x2'));var config=require(_0x54a2('0x3'));var logger=require(_0x54a2('0x4'))(_0x54a2('0x5'));var pm2=require('./config/pm2');var pm2Config=require(_0x54a2('0x6'));var schedule=require(_0x54a2('0x7'));var chat=require(_0x54a2('0x8'));var whatsapp=require(_0x54a2('0x9'));var transcribe=require(_0x54a2('0xa'));var provider=require('./config/schedule/cloud-provider');function main(){return db[_0x54a2('0xb')][_0x54a2('0xc')]()[_0x54a2('0xd')](function(){if(config['seedDB']){return seedDb['default']();}})[_0x54a2('0xd')](function(){return checkLicense['default']();})[_0x54a2('0xd')](function(){return rpc[_0x54a2('0xe')]();})['then'](function(_0x38a9f5){logger[_0x54a2('0xf')](_0x38a9f5);return chat['start']();})[_0x54a2('0xd')](function(){return whatsapp[_0x54a2('0x10')]();})['then'](function(){return schedule[_0x54a2('0x10')]();})[_0x54a2('0xd')](function(){return transcribe[_0x54a2('0x10')]();})[_0x54a2('0xd')](function(){return provider[_0x54a2('0x10')]();})[_0x54a2('0xd')](function(_0x191ee0){logger[_0x54a2('0xf')](_0x191ee0);return pm2['start'](pm2Config);})[_0x54a2('0xd')](function(_0x5e2e9a){var _0x339d74=_0x5e2e9a[_0x54a2('0x11')](function(_0xb61800){return typeof _0xb61800[_0x54a2('0x12')]===_0x54a2('0x13')&&_0xb61800[_0x54a2('0x12')]>=0x0;});if(_0x339d74[_0x54a2('0x14')]>0x0){throw new Error(_0x339d74[_0x54a2('0x14')]+_0x54a2('0x15')+_[_0x54a2('0x16')](_0x339d74,function(_0x528ca9){return'\x22'+_0x528ca9['pm2_env']['name']+'\x22';}));}logger[_0x54a2('0xf')]('Online\x20apps:',_['map'](_['filter'](_0x5e2e9a,{'status':'online'}),_0x54a2('0x17'))[_0x54a2('0x18')]());logger[_0x54a2('0xf')](_0x54a2('0x19'),_[_0x54a2('0x16')](_[_0x54a2('0x11')](_0x5e2e9a,function(_0x466a5b){return _0x466a5b[_0x54a2('0x1a')]!=='online';}),_0x54a2('0x17'))[_0x54a2('0x18')]()||_0x54a2('0x1b'));console['log'](_0x54a2('0x1c'));})[_0x54a2('0x1d')](function(_0x57c95b){console[_0x54a2('0x1e')](_0x54a2('0x1f'),_0x57c95b);logger['error'](_0x54a2('0x20'),_0x57c95b);process[_0x54a2('0x21')](0x1);});}main();