설명 없음

lib.jinja 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. # circusd_watcher_running() always runs last due to its dependency on
  2. # circusd.reloadconfig. If the service is not running it will be started. If
  3. # the service is already running, but changes were detected via the
  4. # xxx_watcher_requirements state, then the service will be restarted.
  5. #
  6. # circusd_watcher_configuration() keeps the appropriate circusd configuration
  7. # file up to date, and triggers a circusd.reloadconfig if any changes are
  8. # detected. It also generates the xxx_watcher_requiremnts state, which serves
  9. # as a dependency of both circusd.reloadconfig and circusd.watcher_running and
  10. # ensures that all requirements of the service are met before either of those
  11. # commands are executed (circusd.reloadconfig starts new services automatically,
  12. # so all requirements need to be met). The difference is that
  13. # circusd.reloadconfig only needs to be run if the actual circusd configuration
  14. # file changed (hence the require_in), while circusd.watcher_running always
  15. # need to be run (hence the watch_in).
  16. #
  17. # The test.succeed_with_changes state is a convenient way of putting all the
  18. # shared requirements for other states in one place. Because of the use of
  19. # 'onchanges', it will report changes if and only if any of its dependencies
  20. # change.
  21. {% macro circusd_watcher_running() %}
  22. circusd.watcher_running:
  23. - endpoint: ipc:///var/lib/circus/endpoint.sock
  24. - require:
  25. - module: circusd.reloadconfig
  26. {% endmacro %}
  27. {% macro circusd_watcher_configuration(name, source, context, extra_requires, extra_onchanges) %}
  28. /etc/circus/conf.d/{{ name }}.ini:
  29. file.managed:
  30. - source: {{ source }}
  31. {% if context %}
  32. - template: jinja
  33. - context: {{ context }}
  34. {% endif %}
  35. - require:
  36. - pkg: circusd
  37. - onchanges_in:
  38. - module: circusd.reloadconfig
  39. {{ name }}_watcher_requirements:
  40. test.succeed_with_changes:
  41. - require:
  42. - service: circusd
  43. {% for item in extra_requires %}
  44. - {{ item }}{% endfor %}
  45. - onchanges:
  46. - file: /etc/circus/conf.d/{{ name }}.ini
  47. {% for item in extra_onchanges %}
  48. - {{ item }}{% endfor %}
  49. - require_in:
  50. - module: circusd.reloadconfig
  51. - watch_in:
  52. - circusd: {{ name }}
  53. {% endmacro %}