K
K
Killir Vanya2292021-12-09 20:35:55
Python
Killir Vanya229, 2021-12-09 20:35:55

How can I pass information between two running files from Procfile Heroku?

I need Heroku hosting to pass information between two running files, one responsible for the discord bot, and the other for the website on which the discord bot will be configured.

The website should take information from another file that is connected to the discord bot using the discord-ext library -ipc, but it does not do this on the hosting

Procfile:

worker: python bot.py
web: gunicorn -k uvicorn.workers.UvicornWorker main:app


error:
21-12-09T17:16:43.379263+00:00 app[web.1]: File "/app/main.py", line 53, in dashboard
2021-12-09T17:16:43.379263+00:00 app[web.1]: guild_count = await ipc_client.request("get_guild_count")

2021-12-09T17:16:43.379266+00:00 app[web.1]: raise client_error(req.connection_key, exc) from exc
2021-12-09T17:16:43.379267+00:00 app[web.1]: aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host localhost:20000 ssl:default [Connect call failed ('127.0.0.1', 20000)]


As I found out, the hosting simply cannot find the file responsible for the bot's discord and gives an error, but can this be somehow avoided?

UPD:
In Procfile you need to write:
web: python bot.py & gunicorn -k uvicorn.workers.UvicornWorker main:app & wait -n

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Shitskov, 2021-12-09
@Zarom

The 2 Dynos in Heroku can communicate via TCP/IP, so depending on what kind of communication is needed, I would choose one of:

  • rest
  • grpc
  • Heroku Redis (queue, optional)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question