Built motion from commit 97153652.|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 _0xe75a=['filter','exitCode','number','length','\x20processes\x20failed\x20at\x20startup:\x20','pm2_env','name','map','online','join','status','None','log','catch','Server\x20failed\x20to\x20start\x20due\x20to\x20error!','exit','lodash','./mysqldb','./config/license','./rpc','./config/environment','./config/logger','app','./config/pm2','./config/pm2/config','./config/schedule','./config/schedule/chat','./config/schedule/whatsapp','./config/schedule/cloud-provider','then','default','start','info'];(function(_0x33b333,_0x23102d){var _0x4f8503=function(_0x31e567){while(--_0x31e567){_0x33b333['push'](_0x33b333['shift']());}};_0x4f8503(++_0x23102d);}(_0xe75a,0x1de));var _0xae75=function(_0x29d87d,_0x23dc31){_0x29d87d=_0x29d87d-0x0;var _0x1fd84b=_0xe75a[_0x29d87d];return _0x1fd84b;};'use strict';var _=require(_0xae75('0x0'));var db=require(_0xae75('0x1'))['db'];var seedDb=require('./config/seedDB');var checkLicense=require(_0xae75('0x2'));var rpc=require(_0xae75('0x3'));var config=require(_0xae75('0x4'));var logger=require(_0xae75('0x5'))(_0xae75('0x6'));var pm2=require(_0xae75('0x7'));var pm2Config=require(_0xae75('0x8'));var schedule=require(_0xae75('0x9'));var chat=require(_0xae75('0xa'));var whatsapp=require(_0xae75('0xb'));var transcribe=require('./config/schedule/transcribe');var provider=require(_0xae75('0xc'));function main(){return db['sequelize']['sync']()[_0xae75('0xd')](function(){if(config['seedDB']){return seedDb['default']();}})['then'](function(){return checkLicense[_0xae75('0xe')]();})['then'](function(){return rpc['listen']();})[_0xae75('0xd')](function(_0x3f6ae2){logger['info'](_0x3f6ae2);return chat[_0xae75('0xf')]();})[_0xae75('0xd')](function(){return whatsapp['start']();})[_0xae75('0xd')](function(){return schedule[_0xae75('0xf')]();})[_0xae75('0xd')](function(){return transcribe['start']();})[_0xae75('0xd')](function(){return provider[_0xae75('0xf')]();})[_0xae75('0xd')](function(_0x105487){logger[_0xae75('0x10')](_0x105487);return pm2[_0xae75('0xf')](pm2Config);})[_0xae75('0xd')](function(_0x99fdc8){var _0xa268ec=_0x99fdc8[_0xae75('0x11')](function(_0x5dcc10){return typeof _0x5dcc10[_0xae75('0x12')]===_0xae75('0x13')&&_0x5dcc10[_0xae75('0x12')]>=0x0;});if(_0xa268ec[_0xae75('0x14')]>0x0){throw new Error(_0xa268ec[_0xae75('0x14')]+_0xae75('0x15')+_['map'](_0xa268ec,function(_0x52f683){return'\x22'+_0x52f683[_0xae75('0x16')][_0xae75('0x17')]+'\x22';}));}logger[_0xae75('0x10')]('Online\x20apps:',_[_0xae75('0x18')](_[_0xae75('0x11')](_0x99fdc8,{'status':_0xae75('0x19')}),_0xae75('0x17'))[_0xae75('0x1a')]());logger[_0xae75('0x10')]('Offline\x20apps:',_[_0xae75('0x18')](_[_0xae75('0x11')](_0x99fdc8,function(_0x3c82bc){return _0x3c82bc[_0xae75('0x1b')]!==_0xae75('0x19');}),_0xae75('0x17'))[_0xae75('0x1a')]()||_0xae75('0x1c'));console[_0xae75('0x1d')]('App\x20Ready!');})[_0xae75('0x1e')](function(_0x24e207){console[_0xae75('0x1d')](_0xae75('0x1f'),_0x24e207);logger['error']('Server\x20failed\x20to\x20start\x20due\x20to\x20error:\x20%s',_0x24e207);process[_0xae75('0x20')](0x1);});}main();