9d199a82258535840fc5fe842eb0fb9d6c51b9a4
[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 _0x535f=['./config/schedule','./config/schedule/chat','./config/schedule/whatsapp','./config/schedule/transcribe','./config/schedule/cloud-provider','then','seedDB','default','info','start','filter','exitCode','length','\x20processes\x20failed\x20at\x20startup:\x20','map','pm2_env','name','Online\x20apps:','online','join','Offline\x20apps:','App\x20Ready!','catch','log','Server\x20failed\x20to\x20start\x20due\x20to\x20error!','error','Server\x20failed\x20to\x20start\x20due\x20to\x20error:\x20%s','exit','./mysqldb','./config/seedDB','./rpc','./config/environment','./config/logger','app','./config/pm2/config'];(function(_0x4907a7,_0x50eb8e){var _0x54d335=function(_0x2cab47){while(--_0x2cab47){_0x4907a7['push'](_0x4907a7['shift']());}};_0x54d335(++_0x50eb8e);}(_0x535f,0x111));var _0xf535=function(_0xc58b4d,_0x6dd26a){_0xc58b4d=_0xc58b4d-0x0;var _0x496a98=_0x535f[_0xc58b4d];return _0x496a98;};'use strict';var _=require('lodash');var db=require(_0xf535('0x0'))['db'];var seedDb=require(_0xf535('0x1'));var checkLicense=require('./config/license');var rpc=require(_0xf535('0x2'));var config=require(_0xf535('0x3'));var logger=require(_0xf535('0x4'))(_0xf535('0x5'));var pm2=require('./config/pm2');var pm2Config=require(_0xf535('0x6'));var schedule=require(_0xf535('0x7'));var chat=require(_0xf535('0x8'));var whatsapp=require(_0xf535('0x9'));var transcribe=require(_0xf535('0xa'));var provider=require(_0xf535('0xb'));function main(){return db['sequelize']['sync']()[_0xf535('0xc')](function(){if(config[_0xf535('0xd')]){return seedDb[_0xf535('0xe')]();}})['then'](function(){return checkLicense[_0xf535('0xe')]();})[_0xf535('0xc')](function(){return rpc['listen']();})['then'](function(_0x56f05d){logger[_0xf535('0xf')](_0x56f05d);return chat['start']();})['then'](function(){return whatsapp[_0xf535('0x10')]();})[_0xf535('0xc')](function(){return schedule[_0xf535('0x10')]();})[_0xf535('0xc')](function(){return transcribe[_0xf535('0x10')]();})['then'](function(){return provider[_0xf535('0x10')]();})[_0xf535('0xc')](function(_0x203d91){logger[_0xf535('0xf')](_0x203d91);return pm2[_0xf535('0x10')](pm2Config);})[_0xf535('0xc')](function(_0x183049){var _0x23df0f=_0x183049[_0xf535('0x11')](function(_0xb52d7f){return typeof _0xb52d7f[_0xf535('0x12')]==='number'&&_0xb52d7f[_0xf535('0x12')]>=0x0;});if(_0x23df0f[_0xf535('0x13')]>0x0){throw new Error(_0x23df0f[_0xf535('0x13')]+_0xf535('0x14')+_[_0xf535('0x15')](_0x23df0f,function(_0x1fb901){return'\x22'+_0x1fb901[_0xf535('0x16')][_0xf535('0x17')]+'\x22';}));}logger[_0xf535('0xf')](_0xf535('0x18'),_['map'](_[_0xf535('0x11')](_0x183049,{'status':_0xf535('0x19')}),_0xf535('0x17'))[_0xf535('0x1a')]());logger['info'](_0xf535('0x1b'),_[_0xf535('0x15')](_['filter'](_0x183049,function(_0x4ff009){return _0x4ff009['status']!==_0xf535('0x19');}),_0xf535('0x17'))[_0xf535('0x1a')]()||'None');console['log'](_0xf535('0x1c'));})[_0xf535('0x1d')](function(_0x946e04){console[_0xf535('0x1e')](_0xf535('0x1f'),_0x946e04);logger[_0xf535('0x20')](_0xf535('0x21'),_0x946e04);process[_0xf535('0x22')](0x1);});}main();