Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
471 views
in Technique[技术] by (71.8m points)

python 3.x - Discord bot deployed on heroku crashes after launch

I made a chat bot for discord channel and if I run it from my local machine, it works well. When I am trying to deploy it on heroku, it doesn't appear online in discord and then it crashes.

I'm trying to find an explanation of the 'status 255' (see logs), but it just means 'mistake'?

After launch the bot makes one 'get' request (I tried to make my bot asynchronous and added one asyncio task) and I think the problem is with that.

def is_xur_here() -> bool:
    """Function checking Xur and returns True/False."""
    xur_url = 'https://paracausal.science/xur/current.json'

    response = requests.get(xur_url, headers=HEADERS)
    data = response.json()

    search_result = False if data is None else True

    return search_result

Also I have another bot deployed on heroku and it works well. I think the problem is with requests so I tried to make another Procfile (web), but heroku reports that it doesn't see any web process.

Procfile:

worker: python bot_main.py

Requirements.txt:

aiohttp==3.6.3
async-timeout==3.0.1
attrs==20.3.0
beautifulsoup4==4.9.3
certifi==2020.11.8
chardet==3.0.4
discord==1.0.1
discord.py==1.5.1
fuzzywuzzy==0.18.0
idna==2.10
lxml==4.6.2
multidict==4.7.6
python-dotenv==0.15.0
python-Levenshtein==0.12.0
requests==2.25.0
soupsieve==2.0.1
urllib3==1.26.2
yarl==1.5.1

Logs from heroku:

2021-01-25T09:29:46.725997+00:00 heroku[worker.1]: State changed from crashed to starting
2021-01-25T09:29:50.461679+00:00 heroku[worker.1]: Starting process with command `python bot_main.py`
2021-01-25T09:29:51.062255+00:00 heroku[worker.1]: State changed from starting to up
2021-01-25T09:29:54.253986+00:00 heroku[worker.1]: Process exited with status 255

Here is the bot code for convenience if someone wants to look it through. I really don't know what else may be nessessary to get the answer and I will be grateful for any direction.

question from:https://stackoverflow.com/questions/65884083/discord-bot-deployed-on-heroku-crashes-after-launch

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...