beeswax_server.py 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #!/usr/bin/env python
  2. # Licensed to Cloudera, Inc. under one
  3. # or more contributor license agreements. See the NOTICE file
  4. # distributed with this work for additional information
  5. # regarding copyright ownership. Cloudera, Inc. licenses this file
  6. # to you under the Apache License, Version 2.0 (the
  7. # "License"); you may not use this file except in compliance
  8. # with the License. You may obtain a copy of the License at
  9. #
  10. # http://www.apache.org/licenses/LICENSE-2.0
  11. #
  12. # Unless required by applicable law or agreed to in writing, software
  13. # distributed under the License is distributed on an "AS IS" BASIS,
  14. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. # See the License for the specific language governing permissions and
  16. # limitations under the License.
  17. """
  18. Starts the beeswax server.
  19. """
  20. from django.core.management.base import NoArgsCommand
  21. import beeswax.conf
  22. import beeswax.hive_site
  23. import desktop.conf
  24. import hadoop.conf
  25. import os
  26. import logging
  27. LOG = logging.getLogger(__name__)
  28. class Command(NoArgsCommand):
  29. """ Starts beeswax daemon. """
  30. def handle_noargs(self, **options):
  31. env = os.environ.copy()
  32. env['HADOOP_HOME'] = hadoop.conf.HADOOP_HOME.get()
  33. if hadoop.conf.HADOOP_CONF_DIR.get():
  34. env['HADOOP_CONF_DIR'] = hadoop.conf.HADOOP_CONF_DIR.get()
  35. if beeswax.conf.BEESWAX_HIVE_CONF_DIR.get():
  36. env['HIVE_CONF_DIR'] = beeswax.conf.BEESWAX_HIVE_CONF_DIR.get()
  37. bin = beeswax.conf.BEESWAX_SERVER_BIN.get()
  38. # Host that desktop is running on
  39. # - If the ip is configured to be 0, assume localhost
  40. dt_host = desktop.conf.HTTP_HOST.get()
  41. if dt_host == '0.0.0.0':
  42. dt_host = '127.0.0.1'
  43. args = [
  44. os.path.basename(bin),
  45. '--beeswax',
  46. str(beeswax.conf.BEESWAX_SERVER_PORT.get()),
  47. '--desktop-host',
  48. str(dt_host),
  49. '--desktop-port',
  50. "8000",
  51. #str(desktop.conf.HTTP_PORT.get()),
  52. ]
  53. # Running on HTTPS?
  54. if desktop.conf.is_https_enabled():
  55. args.append('--desktop-https')
  56. args.append('true')
  57. # Start metastore as well?
  58. is_local, host, port = beeswax.hive_site.get_metastore()
  59. if not is_local:
  60. LOG.info("Beeswax configured to use external metastore at %s:%s" % (host, port))
  61. else:
  62. args += [ '--metastore', str(beeswax.conf.BEESWAX_META_SERVER_PORT.get()) ]
  63. LOG.info("Executing %r (%r) (%r)" % (bin, args, env))
  64. # Use exec, so that this takes only one process.
  65. os.execve(bin, args, env)