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.

52 lines
1.7 KiB

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