appspec.yml未执行脚本。

huangapple go评论46阅读模式
英文:

appspec.yml does not execute scipts

问题

这是您提供的内容的中文翻译:

我正在使用AWS CodePipeline构建代码流水线,为此我构建了一个appspec.yml文件来部署在服务器上。appspec文件部分正常工作,并将代码从源位置传送到目标位置,但是它不执行代码文件夹中的脚本,并且也不报错。

以下是appspec.yml文件的内容:

version: 0.0
os: linux
files:
  - source: /
    destination: /home/ubuntu
    file_exists_behavior: OVERWRITE
hooks:
  ApplicationStop:
    - location: scripts/stop_server.sh
      timeout: 300
      runas: root
  BeforeInstall:
    - location: scripts/deploy_server.sh
      timeout: 300
      runas: root
  ApplicationStart:
    - location: scripts/start_server.sh
      timeout: 300
      runas: root

以下是脚本文件的内容:

#!/bin/bash

sudo systemctl stop HYPNOS.service

sudo systemctl disable HYPNOS

sudo systemctl daemon-reload

希望这对您有所帮助。

英文:

I am building the code pipeline using aws code pipeline and for that I build a appspec.yml file to deploy on server the appspec files portion work correctly and bring the code from source to destination and then It does not execute the Scripts in the script folder of the code and also does not give any error

here is appspec.yml

version: 0.0
os: linux
files:
  - source: /
    destination: /home/ubuntu
    file_exists_behavior: OVERWRITE
hooks:
ApplicationStop:
      - location: scripts/stop_server.sh
        timeout: 300
        runas: root
        
BeforeInstall:
      - location: scripts/deploy_server.sh
        timeout: 300
        runas: root
       
ApplicationStart:
      - location: scripts/start_server.sh
        timeout: 300
        runas: root

and here is the script file

#!bin/bash

sudo systemctl stop HYPNOS.service

sudo systemctl disable HYPNOS

sudo systemctl daemon-reload

答案1

得分: 0

You need indentation after hooks. It should be:

version: 0.0
os: linux
files:
  - source: /
    destination: /home/ubuntu
    file_exists_behavior: OVERWRITE
hooks:
  ApplicationStop:
    - location: scripts/stop_server.sh
      timeout: 300
      runas: root

  BeforeInstall:
    - location: scripts/deploy_server.sh
      timeout: 300
      runas: root

  ApplicationStart:
    - location: scripts/start_server.sh
      timeout: 300
      runas: root
英文:

You need indentation after hooks. It should be:

version: 0.0
os: linux
files:
  - source: /
    destination: /home/ubuntu
    file_exists_behavior: OVERWRITE
hooks:
ApplicationStop:
      - location: scripts/stop_server.sh
        timeout: 300
        runas: root
        
BeforeInstall:
      - location: scripts/deploy_server.sh
        timeout: 300
        runas: root
       
ApplicationStart:
      - location: scripts/start_server.sh
        timeout: 300
        runas: root

huangapple
  • 本文由 发表于 2023年7月20日 17:22:08
  • 转载请务必保留本文链接:https://go.coder-hub.com/76728418.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定