Built motion from commit ecb45b58.|2.6.31
[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 _0x873a=['Offline\x20apps:','online','None','log','catch','Server\x20failed\x20to\x20start\x20due\x20to\x20error!','Server\x20failed\x20to\x20start\x20due\x20to\x20error:\x20%s','exit','lodash','./mysqldb','./config/seedDB','./rpc','app','./config/pm2','./config/schedule','./config/schedule/chat','./config/schedule/transcribe','sequelize','sync','then','seedDB','default','listen','start','info','filter','exitCode','number','length','map','pm2_env','name','Online\x20apps:','join'];(function(_0x66f487,_0x11815f){var _0x39229b=function(_0x10e210){while(--_0x10e210){_0x66f487['push'](_0x66f487['shift']());}};_0x39229b(++_0x11815f);}(_0x873a,0x1c2));var _0xa873=function(_0x58be26,_0x3595c5){_0x58be26=_0x58be26-0x0;var _0x49df27=_0x873a[_0x58be26];return _0x49df27;};'use strict';var _=require(_0xa873('0x0'));var db=require(_0xa873('0x1'))['db'];var seedDb=require(_0xa873('0x2'));var checkLicense=require('./config/license');var rpc=require(_0xa873('0x3'));var config=require('./config/environment');var logger=require('./config/logger')(_0xa873('0x4'));var pm2=require(_0xa873('0x5'));var pm2Config=require('./config/pm2/config');var schedule=require(_0xa873('0x6'));var chat=require(_0xa873('0x7'));var whatsapp=require('./config/schedule/whatsapp');var transcribe=require(_0xa873('0x8'));var provider=require('./config/schedule/cloud-provider');function main(){return db[_0xa873('0x9')][_0xa873('0xa')]()[_0xa873('0xb')](function(){if(config[_0xa873('0xc')]){return seedDb[_0xa873('0xd')]();}})[_0xa873('0xb')](function(){return checkLicense[_0xa873('0xd')]();})[_0xa873('0xb')](function(){return rpc[_0xa873('0xe')]();})[_0xa873('0xb')](function(_0xc2fb4f){logger['info'](_0xc2fb4f);return chat[_0xa873('0xf')]();})['then'](function(){return whatsapp[_0xa873('0xf')]();})['then'](function(){return schedule['start']();})[_0xa873('0xb')](function(){return transcribe['start']();})[_0xa873('0xb')](function(){return provider[_0xa873('0xf')]();})['then'](function(_0x33cc06){logger[_0xa873('0x10')](_0x33cc06);return pm2[_0xa873('0xf')](pm2Config);})['then'](function(_0x3ed9e3){var _0x42c966=_0x3ed9e3[_0xa873('0x11')](function(_0x4f9c74){return typeof _0x4f9c74[_0xa873('0x12')]===_0xa873('0x13')&&_0x4f9c74[_0xa873('0x12')]>=0x0;});if(_0x42c966['length']>0x0){throw new Error(_0x42c966[_0xa873('0x14')]+'\x20processes\x20failed\x20at\x20startup:\x20'+_[_0xa873('0x15')](_0x42c966,function(_0x5189a6){return'\x22'+_0x5189a6[_0xa873('0x16')][_0xa873('0x17')]+'\x22';}));}logger['info'](_0xa873('0x18'),_[_0xa873('0x15')](_[_0xa873('0x11')](_0x3ed9e3,{'status':'online'}),_0xa873('0x17'))[_0xa873('0x19')]());logger[_0xa873('0x10')](_0xa873('0x1a'),_[_0xa873('0x15')](_[_0xa873('0x11')](_0x3ed9e3,function(_0x39724b){return _0x39724b['status']!==_0xa873('0x1b');}),_0xa873('0x17'))[_0xa873('0x19')]()||_0xa873('0x1c'));console[_0xa873('0x1d')]('App\x20Ready!');})[_0xa873('0x1e')](function(_0x146c08){console['log'](_0xa873('0x1f'),_0x146c08);logger['error'](_0xa873('0x20'),_0x146c08);process[_0xa873('0x21')](0x1);});}main();