须藤:服务:找不到命令

时间:2021-04-21 09:42:04

标签: python amazon-web-services amazon-ec2 discord aws-code-deploy

在之前的部署中,我的 appspec.yml 文件中有 ApplicationStop 但已将其删除。现在,CodeDeploy 正在尝试查找我之前部署中存在的文件。 我找到了其他答案,但没有一个有效:

  1. sudo service codedeploy-agent stop 在 CloudShell 中键入此内容时,出现错误 - sudo: service: command not found
  2. aws deploy create-deployment --application-name APPLICATION --deployment-group-name GROUP --ignore-application-stop-failures --s3-location bundleType=tar,bucket=BUCKET,key=KEY --description "Ignore ApplicationStop failures due to broken script" 键入此内容并替换 APPLICATION、GROUP、BUCKET 和 KEY 后,代码部署开始。但是,部署无论如何都会失败并出现错误。 enter image description here

我的文件: appspec.yml:

version: 0.0
os: linux
files:
  - source: /
    destination: /home/discordbot
hooks:
  AfterInstall:
    - location: scripts/RunMyBot.sh
      timeout: 300
      runas: root

RunMyBot.sh

#!bin/bash

easy_install pip
pip install -r /home/discordbot/requirements.txt

file="/lib/systemd/system/mypythonservice.service"
echo "[Unit]" > $file
echo "Description=My Python Service" > $file
echo "After=multi-user.target" >> $file

echo "[Service]" >> $file
echo "Type=idle" >> $file
echo "ExecStart=/usr/bin/python /home/discordbot/botMain.py" >> $file
echo "Restart=on-failure" >> $file

echo "[Install]" >> $file
echo "WantedBy=multi-user.target" >> $file
cat $file

sudo chmod 644 /lib/systemd/system/mypythonservice.service

sudo systemctl daemon-reload

sudo systemctl enable mypythonservice.service

我只是无法成功部署我的代码,27 次部署失败。 我的python代码很简单,只需要一直运行。它接受来自用户的命令并返回输出。代码位于 github 中。

0 个答案:

没有答案