server.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * Copyright © 2016-2022 The Thingsboard Authors
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. const config = require('config'), logger = require('./config/logger')._logger('main');
  17. logger.info('===CONFIG BEGIN===');
  18. logger.info(JSON.stringify(config, null, 4));
  19. logger.info('===CONFIG END===');
  20. const serviceType = config.get('queue_type');
  21. switch (serviceType) {
  22. case 'kafka':
  23. logger.info('Starting kafka template.');
  24. require('./queue/kafkaTemplate');
  25. logger.info('kafka template started.');
  26. break;
  27. case 'pubsub':
  28. logger.info('Starting Pub/Sub template.')
  29. require('./queue/pubSubTemplate');
  30. logger.info('Pub/Sub template started.')
  31. break;
  32. case 'aws-sqs':
  33. logger.info('Starting Aws Sqs template.')
  34. require('./queue/awsSqsTemplate');
  35. logger.info('Aws Sqs template started.')
  36. break;
  37. case 'rabbitmq':
  38. logger.info('Starting RabbitMq template.')
  39. require('./queue/rabbitmqTemplate');
  40. logger.info('RabbitMq template started.')
  41. break;
  42. case 'service-bus':
  43. logger.info('Starting Azure Service Bus template.')
  44. require('./queue/serviceBusTemplate');
  45. logger.info('Azure Service Bus template started.')
  46. break;
  47. default:
  48. logger.error('Unknown service type: ', serviceType);
  49. process.exit(-1);
  50. }
  51. require('./api/httpServer');