由于找不到进程,CodeDeploy 在 ApplicationStop 中失败

时间:2021-05-02 17:38:14

标签: python bash amazon-web-services aws-code-deploy

我正在使用 nohup python3 botMain.py & 运行我的 Python 代码。当我更新我的代码时,我想在 ApplicationStop 阶段终止这个进程。当我尝试使用 ps -ef | grep botMain.py | grep -v grep | awk '{print $2}'then kill PID 在 cli 中终止进程时,它工作正常并且进程被终止。 当我在 bash 中使用相同的脚本时, stop_bot.sh

#!bin/bash

ps -ef | grep botMain.py | grep -v grep | awk '{print $2}' | xargs kill -9

CodeDeploy 在 ApplicationStop 中失败并出现以下错误, enter image description here

appspec.yml

version: 0.0
os: linux
files:
  - source: /
    destination: /home/mybot
hooks:
  AfterInstall:
    - location: scripts/install_dependencies.sh
      timeout: 300
      runas: root
  ApplicationStart:
    - location: scripts/start_bot.sh
      timeout: 300
      runas: root
  ApplicationStop:
    - location: scripts/stop_bot.sh
      timeout: 300
      runas: root

我想在新部署期间自动终止进程,而不是每次在 cli 中都手动执行。

0 个答案:

没有答案