【发布时间】:2021-05-01 18:52:55
【问题描述】:
我对我的 botMain.py 文件进行了一些更改。 CodeDeploy 成功,但更改在应用程序中无效。所以,我编辑了我的 RunMyBot.sh 文件,但仍然没有任何变化。
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/RunMyBot.sh
timeout: 300
runas: root
RunMyBot.sh(新)
#!bin/bash
sudo /usr/bin/pm2 restart myBot
nohup python3 botMain.py & /dev/null 2> /dev/null < /dev/null &
RunMyBot.sh(旧)
serverfile="/lib/systemd/system/mypythonservice.service"
echo "[Unit]" > $serverfile
echo "Description=My Python Service" > $serverfile
echo "After=multi-user.target" >> $serverfile
echo "[Service]" >> $serverfile
echo "Type=idle" >> $serverfile
echo "ExecStart=/usr/bin/python /home/mybot/botMain.py" >> $serverfile
echo "Restart=on-failure" >> $serverfile
echo "[Install]" >> $serverfile
echo "WantedBy=multi-user.target" >> $serverfile
cat $serverfile
sudo chmod 644 /lib/systemd/system/mypythonservice.service
sudo systemctl daemon-reload
sudo systemctl enable mypythonservice.service
我的实例用户数据中也有相同的服务器文件脚本,所以我从 RunMyBot.sh 中删除了它
【问题讨论】:
标签: python amazon-web-services amazon-ec2 aws-code-deploy