Built motion from commit e6806ed6.|2.6.0
[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 _0xae53=['./config/logger','app','./config/pm2','./config/pm2/config','./config/schedule','./config/schedule/whatsapp','./config/schedule/cloud-provider','sequelize','sync','then','seedDB','default','listen','info','start','exitCode','number','length','\x20processes\x20failed\x20at\x20startup:\x20','map','pm2_env','name','online','join','Offline\x20apps:','filter','status','None','log','Server\x20failed\x20to\x20start\x20due\x20to\x20error!','error','Server\x20failed\x20to\x20start\x20due\x20to\x20error:\x20%s','exit','lodash','./config/seedDB','./config/license','./rpc'];(function(_0x2a67fe,_0x295c09){var _0x57e726=function(_0x280573){while(--_0x280573){_0x2a67fe['push'](_0x2a67fe['shift']());}};_0x57e726(++_0x295c09);}(_0xae53,0x16e));var _0x3ae5=function(_0x1cc8fe,_0x105328){_0x1cc8fe=_0x1cc8fe-0x0;var _0x230054=_0xae53[_0x1cc8fe];return _0x230054;};'use strict';var _=require(_0x3ae5('0x0'));var db=require('./mysqldb')['db'];var seedDb=require(_0x3ae5('0x1'));var checkLicense=require(_0x3ae5('0x2'));var rpc=require(_0x3ae5('0x3'));var config=require('./config/environment');var logger=require(_0x3ae5('0x4'))(_0x3ae5('0x5'));var pm2=require(_0x3ae5('0x6'));var pm2Config=require(_0x3ae5('0x7'));var schedule=require(_0x3ae5('0x8'));var chat=require('./config/schedule/chat');var whatsapp=require(_0x3ae5('0x9'));var transcribe=require('./config/schedule/transcribe');var provider=require(_0x3ae5('0xa'));function main(){return db[_0x3ae5('0xb')][_0x3ae5('0xc')]()[_0x3ae5('0xd')](function(){if(config[_0x3ae5('0xe')]){return seedDb[_0x3ae5('0xf')]();}})[_0x3ae5('0xd')](function(){return checkLicense[_0x3ae5('0xf')]();})['then'](function(){return rpc[_0x3ae5('0x10')]();})['then'](function(_0x8147f4){logger[_0x3ae5('0x11')](_0x8147f4);return chat[_0x3ae5('0x12')]();})[_0x3ae5('0xd')](function(){return whatsapp[_0x3ae5('0x12')]();})['then'](function(){return schedule[_0x3ae5('0x12')]();})[_0x3ae5('0xd')](function(){return transcribe[_0x3ae5('0x12')]();})['then'](function(){return provider['start']();})[_0x3ae5('0xd')](function(_0x5943e6){logger[_0x3ae5('0x11')](_0x5943e6);return pm2[_0x3ae5('0x12')](pm2Config);})[_0x3ae5('0xd')](function(_0x45175c){var _0x352f36=_0x45175c['filter'](function(_0x216c62){return typeof _0x216c62[_0x3ae5('0x13')]===_0x3ae5('0x14')&&_0x216c62['exitCode']>=0x0;});if(_0x352f36['length']>0x0){throw new Error(_0x352f36[_0x3ae5('0x15')]+_0x3ae5('0x16')+_[_0x3ae5('0x17')](_0x352f36,function(_0x445a31){return'\x22'+_0x445a31[_0x3ae5('0x18')][_0x3ae5('0x19')]+'\x22';}));}logger[_0x3ae5('0x11')]('Online\x20apps:',_['map'](_['filter'](_0x45175c,{'status':_0x3ae5('0x1a')}),_0x3ae5('0x19'))[_0x3ae5('0x1b')]());logger[_0x3ae5('0x11')](_0x3ae5('0x1c'),_[_0x3ae5('0x17')](_[_0x3ae5('0x1d')](_0x45175c,function(_0x533971){return _0x533971[_0x3ae5('0x1e')]!==_0x3ae5('0x1a');}),_0x3ae5('0x19'))[_0x3ae5('0x1b')]()||_0x3ae5('0x1f'));console[_0x3ae5('0x20')]('App\x20Ready!');})['catch'](function(_0x28adc9){console[_0x3ae5('0x20')](_0x3ae5('0x21'),_0x28adc9);logger[_0x3ae5('0x22')](_0x3ae5('0x23'),_0x28adc9);process[_0x3ae5('0x24')](0x1);});}main();