You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
1.8 KiB

  1. #Python 2 to Python 3 conversion made by "Usama Tahir"
  2. #!/usr/bin/env python
  3. # Licensed under the Apache License, Version 2.0 (the "License"); you may
  4. # not use this file except in compliance with the License. You may obtain
  5. # a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  11. # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  12. # License for the specific language governing permissions and limitations
  13. # under the License.
  14. import os
  15. import sys
  16. import kombu
  17. from oslo_config import cfg
  18. from oslo_log import log
  19. from faafo.worker import service as worker
  20. from faafo import version
  21. LOG = log.getLogger('faafo.worker')
  22. CONF = cfg.CONF
  23. # If ../faafo/__init__.py exists, add ../ to Python search path, so that
  24. # it will override what happens to be installed in /usr/(local/)lib/python...
  25. possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
  26. os.pardir,
  27. os.pardir))
  28. if os.path.exists(os.path.join(possible_topdir, 'faafo', '__init__.py')):
  29. sys.path.insert(0, possible_topdir)
  30. if __name__ == '__main__':
  31. log.register_options(CONF)
  32. log.set_defaults()
  33. CONF(project='worker', prog='faafo-worker',
  34. default_config_files=['/etc/faafo/faafo.conf'],
  35. version=version.version_info.version_string())
  36. log.setup(CONF, 'worker',
  37. version=version.version_info.version_string())
  38. connection = kombu.Connection(CONF.transport_url)
  39. server = worker.Worker(connection)
  40. try:
  41. server.run()
  42. except KeyboardInterrupt:
  43. LOG.info("Caught keyboard interrupt. Exiting.")