1

I have connected AWS to github

appspec.yml

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

RunMyBot.sh

#!bin/bash

cd /home/mybot/
yum install -y python3-pip python3 python3-setuptools
sudo python3 -m pip install --user --upgrade pip
pip3 install -r requirements.txt
python botMain.py

Error:

enter image description here

I want to run my main file - botMain.py, but it doesn't run.

I tried removing the install lines from script coz it said they were already installed, but still I was getting a timeout and my botMain.py was not running.

DeadPool
  • 185
  • 2
  • 13

1 Answers1

0

Probably it should be python3, not python. But anyway, your deployment hangs because if botMain.py is a server, it just starts and does not finish. Due to this, CD timeouts waiting for botMain.py to complete its execution which never happens.

To properly run your botMain.py you should run it a daemon service. For that you can create custom unit file for systemd on linux. One example of that is here.

Marcin
  • 215,873
  • 14
  • 235
  • 294
  • So, do I need to create another script for BeforeInstall? I added the code from the link you gave with my own paths to RunMyBot.sh. But, I am getting the same error - ScriptTimedOut. Also warnings: [stderr]Vim: Warning: Output is not to a terminal [stderr]Vim: Warning: Input is not from a terminal – DeadPool Apr 19 '21 at 11:33
  • @DeadPool You can't run your code the way you do because it will hang. You have to create a systemd service as I explained. Have you tried that? – Marcin Apr 22 '21 at 03:18
  • yes I did. I have added the systemd lines in my RunMybot.sh. And I tried using another way before for which I had added ApplicationStop but later removed it. During deployment it is now trying to find the file that I used for ApplicationStop which doesn't exist. I found some solutions on net, but none of them are working. It gives me the error- 'Failed to get D-Bus connection: Operation not permitted' when I try to restart code-deploy. It can't find code deploy. (https://stackoverflow.com/questions/67193222/sudo-service-command-not-found) – DeadPool Apr 22 '21 at 05:56