d00c5ff0915d8123e4caab2c4437c262b33f90a1
[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 _0xf842=['seedDB','default','listen','info','start','filter','exitCode','length','map','pm2_env','name','Online\x20apps:','join','Offline\x20apps:','None','log','App\x20Ready!','catch','error','exit','lodash','./mysqldb','./config/seedDB','./config/license','./config/environment','./config/logger','app','./config/pm2','./config/pm2/config','./config/schedule/chat','./config/schedule/whatsapp','./config/schedule/transcribe','sequelize','sync','then'];(function(_0x3cb30b,_0x504b3e){var _0x2ca717=function(_0x32a3d9){while(--_0x32a3d9){_0x3cb30b['push'](_0x3cb30b['shift']());}};_0x2ca717(++_0x504b3e);}(_0xf842,0x172));var _0x2f84=function(_0x5a3cf0,_0x160a68){_0x5a3cf0=_0x5a3cf0-0x0;var _0x5a64ee=_0xf842[_0x5a3cf0];return _0x5a64ee;};'use strict';var _=require(_0x2f84('0x0'));var db=require(_0x2f84('0x1'))['db'];var seedDb=require(_0x2f84('0x2'));var checkLicense=require(_0x2f84('0x3'));var rpc=require('./rpc');var config=require(_0x2f84('0x4'));var logger=require(_0x2f84('0x5'))(_0x2f84('0x6'));var pm2=require(_0x2f84('0x7'));var pm2Config=require(_0x2f84('0x8'));var schedule=require('./config/schedule');var chat=require(_0x2f84('0x9'));var whatsapp=require(_0x2f84('0xa'));var transcribe=require(_0x2f84('0xb'));var provider=require('./config/schedule/cloud-provider');function main(){return db[_0x2f84('0xc')][_0x2f84('0xd')]()[_0x2f84('0xe')](function(){if(config[_0x2f84('0xf')]){return seedDb[_0x2f84('0x10')]();}})[_0x2f84('0xe')](function(){return checkLicense[_0x2f84('0x10')]();})[_0x2f84('0xe')](function(){return rpc[_0x2f84('0x11')]();})[_0x2f84('0xe')](function(_0x4edf3b){logger[_0x2f84('0x12')](_0x4edf3b);return chat['start']();})[_0x2f84('0xe')](function(){return whatsapp[_0x2f84('0x13')]();})[_0x2f84('0xe')](function(){return schedule[_0x2f84('0x13')]();})[_0x2f84('0xe')](function(){return transcribe[_0x2f84('0x13')]();})[_0x2f84('0xe')](function(){return provider[_0x2f84('0x13')]();})[_0x2f84('0xe')](function(_0x20e0d0){logger[_0x2f84('0x12')](_0x20e0d0);return pm2[_0x2f84('0x13')](pm2Config);})['then'](function(_0x489f51){var _0x50d906=_0x489f51[_0x2f84('0x14')](function(_0x4073d6){return typeof _0x4073d6[_0x2f84('0x15')]==='number'&&_0x4073d6[_0x2f84('0x15')]>=0x0;});if(_0x50d906[_0x2f84('0x16')]>0x0){throw new Error(_0x50d906[_0x2f84('0x16')]+'\x20processes\x20failed\x20at\x20startup:\x20'+_[_0x2f84('0x17')](_0x50d906,function(_0xbe3e4f){return'\x22'+_0xbe3e4f[_0x2f84('0x18')][_0x2f84('0x19')]+'\x22';}));}logger['info'](_0x2f84('0x1a'),_['map'](_[_0x2f84('0x14')](_0x489f51,{'status':'online'}),'name')[_0x2f84('0x1b')]());logger[_0x2f84('0x12')](_0x2f84('0x1c'),_[_0x2f84('0x17')](_[_0x2f84('0x14')](_0x489f51,function(_0x4600af){return _0x4600af['status']!=='online';}),_0x2f84('0x19'))[_0x2f84('0x1b')]()||_0x2f84('0x1d'));console[_0x2f84('0x1e')](_0x2f84('0x1f'));})[_0x2f84('0x20')](function(_0x546447){console[_0x2f84('0x1e')]('Server\x20failed\x20to\x20start\x20due\x20to\x20error!',_0x546447);logger[_0x2f84('0x21')]('Server\x20failed\x20to\x20start\x20due\x20to\x20error:\x20%s',_0x546447);process[_0x2f84('0x22')](0x1);});}main();