61e0cdea169d5b2cae7d753244a53e248a4e8449
[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 _0x13f5=['exitCode','length','\x20processes\x20failed\x20at\x20startup:\x20','map','pm2_env','name','Online\x20apps:','online','join','Offline\x20apps:','None','log','App\x20Ready!','catch','exit','lodash','./mysqldb','./config/seedDB','./config/license','./config/environment','./config/pm2','./config/pm2/config','./config/schedule','./config/schedule/chat','./config/schedule/whatsapp','./config/schedule/transcribe','./config/schedule/cloud-provider','sequelize','sync','then','seedDB','default','listen','start','info','filter'];(function(_0x4eb6ec,_0x7f2520){var _0x58881b=function(_0x4f375f){while(--_0x4f375f){_0x4eb6ec['push'](_0x4eb6ec['shift']());}};_0x58881b(++_0x7f2520);}(_0x13f5,0xc3));var _0x513f=function(_0x122ef9,_0x451d2a){_0x122ef9=_0x122ef9-0x0;var _0x42fba0=_0x13f5[_0x122ef9];return _0x42fba0;};'use strict';var _=require(_0x513f('0x0'));var db=require(_0x513f('0x1'))['db'];var seedDb=require(_0x513f('0x2'));var checkLicense=require(_0x513f('0x3'));var rpc=require('./rpc');var config=require(_0x513f('0x4'));var logger=require('./config/logger')('app');var pm2=require(_0x513f('0x5'));var pm2Config=require(_0x513f('0x6'));var schedule=require(_0x513f('0x7'));var chat=require(_0x513f('0x8'));var whatsapp=require(_0x513f('0x9'));var transcribe=require(_0x513f('0xa'));var provider=require(_0x513f('0xb'));function main(){return db[_0x513f('0xc')][_0x513f('0xd')]()[_0x513f('0xe')](function(){if(config[_0x513f('0xf')]){return seedDb[_0x513f('0x10')]();}})['then'](function(){return checkLicense[_0x513f('0x10')]();})[_0x513f('0xe')](function(){return rpc[_0x513f('0x11')]();})[_0x513f('0xe')](function(_0x88288b){logger['info'](_0x88288b);return chat[_0x513f('0x12')]();})[_0x513f('0xe')](function(){return whatsapp['start']();})[_0x513f('0xe')](function(){return schedule[_0x513f('0x12')]();})[_0x513f('0xe')](function(){return transcribe[_0x513f('0x12')]();})[_0x513f('0xe')](function(){return provider[_0x513f('0x12')]();})[_0x513f('0xe')](function(_0x265cd7){logger[_0x513f('0x13')](_0x265cd7);return pm2[_0x513f('0x12')](pm2Config);})[_0x513f('0xe')](function(_0x359478){var _0x3874d1=_0x359478[_0x513f('0x14')](function(_0x57fd65){return typeof _0x57fd65[_0x513f('0x15')]==='number'&&_0x57fd65[_0x513f('0x15')]>=0x0;});if(_0x3874d1[_0x513f('0x16')]>0x0){throw new Error(_0x3874d1[_0x513f('0x16')]+_0x513f('0x17')+_[_0x513f('0x18')](_0x3874d1,function(_0x584305){return'\x22'+_0x584305[_0x513f('0x19')][_0x513f('0x1a')]+'\x22';}));}logger['info'](_0x513f('0x1b'),_['map'](_[_0x513f('0x14')](_0x359478,{'status':_0x513f('0x1c')}),'name')[_0x513f('0x1d')]());logger[_0x513f('0x13')](_0x513f('0x1e'),_[_0x513f('0x18')](_[_0x513f('0x14')](_0x359478,function(_0x1e3a46){return _0x1e3a46['status']!==_0x513f('0x1c');}),_0x513f('0x1a'))['join']()||_0x513f('0x1f'));console[_0x513f('0x20')](_0x513f('0x21'));})[_0x513f('0x22')](function(_0x3d85f7){console[_0x513f('0x20')]('Server\x20failed\x20to\x20start\x20due\x20to\x20error!',_0x3d85f7);logger['error']('Server\x20failed\x20to\x20start\x20due\x20to\x20error:\x20%s',_0x3d85f7);process[_0x513f('0x23')](0x1);});}main();