停止-更新-从 saltstack highstate 开始?

Stop-update-start with saltstack highstate?

Saltstack 负责更新 Web 应用程序代码(uwsgi,Python,如果重要的话)。这个想法是从档案中更新代码。最好为此使用一个盐命令 - state.highstate.

问题是,在更新期间应用程序代码不应该是 运行ning,所以 service.stopservice.start 是 运行 在 state.highstate 附近.

有什么方法可以将这个更新逻辑包含到highstate中吗?或者也许还有其他更合适的命令?

在约瑟夫·霍尔 (Joseph Hall) 的《精通 SaltStack》第 2 版中找到以下内容。

..., consider a web application that makes use of Apache. When the codebase on a production server changes, Apache should be turned off, so as to avoid errors with the code that has not yet finished being installed.

关键是要使用 prereq,这里是根据我的存档案例改编的书本示例:

my_service: 
  service: 
    - running
    - name: my_service
    - watch: 
      - cmd: my_archive

my_archive: 
  cmd: 
    - run
    - name: "/bin/tar -zxf my.tar.gz -C {{ code_dir }}"
    - require:
      - file: my.tar.gz
    ... 

shutdown_my_service: 
  service: 
    - dead 
    - name: my_service 
    - prereq: 
      - cmd: my_archive

(这里写的我没仔细看,但是很容易看出思路)