| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- # circusd_watcher_running() always runs last due to its dependency on
- # circusd.reloadconfig. If the service is not running it will be started. If
- # the service is already running, but changes were detected via the
- # xxx_watcher_requirements state, then the service will be restarted.
- #
- # circusd_watcher_configuration() keeps the appropriate circusd configuration
- # file up to date, and triggers a circusd.reloadconfig if any changes are
- # detected. It also generates the xxx_watcher_requiremnts state, which serves
- # as a dependency of both circusd.reloadconfig and circusd.watcher_running and
- # ensures that all requirements of the service are met before either of those
- # commands are executed (circusd.reloadconfig starts new services automatically,
- # so all requirements need to be met). The difference is that
- # circusd.reloadconfig only needs to be run if the actual circusd configuration
- # file changed (hence the require_in), while circusd.watcher_running always
- # need to be run (hence the watch_in).
- #
- # The test.succeed_with_changes state is a convenient way of putting all the
- # shared requirements for other states in one place. Because of the use of
- # 'onchanges', it will report changes if and only if any of its dependencies
- # change.
- {% macro circusd_watcher_running() %}
- circusd.watcher_running:
- - endpoint: ipc:///var/lib/circus/endpoint.sock
- - require:
- - module: circusd.reloadconfig
- {% endmacro %}
- {% macro circusd_watcher_configuration(name, source, context, extra_requires, extra_onchanges) %}
- /etc/circus/conf.d/{{ name }}.ini:
- file.managed:
- - source: {{ source }}
- {% if context %}
- - template: jinja
- - context: {{ context }}
- {% endif %}
- - require:
- - file: /etc/circus/conf.d
- - onchanges_in:
- - module: circusd.reloadconfig
- {{ name }}_watcher_requirements:
- test.succeed_with_changes:
- - require:
- - service: circusd
- {% for item in extra_requires %}
- - {{ item }}{% endfor %}
- - onchanges:
- - file: /etc/circus/conf.d/{{ name }}.ini
- {% for item in extra_onchanges %}
- - {{ item }}{% endfor %}
- - require_in:
- - module: circusd.reloadconfig
- - watch_in:
- - circusd: {{ name }}
- {% endmacro %}
|