What is the easiest way to deploy a python app with only two .py files but keep it in one dyno? My files are friend.py
and foe.py
and my Procfile looks like this:
worker: python friend.py
worker: python foe.py
But when deployed to Heroku, the only dyno I have is foe.py. I've read other similar questions but they seem to complicated and I don't yet understand the inner workings of a python web application.
If they are distinct processes working in parallel, the most direct path is two dynos, using different names (actually, friend
and foe
would work fine as process names) in the Procfile
. Right now, you are using the name worker
twice, so foe.py
shows up because it's the last one defined. Two things to keep in mind -
Procfile
can be arbitrary; as far as I know, the only "special" name is web
, which tells Heroku to expect that process to bind to a port and accept HTTP traffic from the routing mesh. worker
isn't special; it's just a convention people tend to use for "something running other than the web dyno" If you really need only one dyno (cost?), you could write a third script whose sole job is to spawn friend.py
and foe.py
as subprocesses. In that case, everything comes up and down as a unit; you can't manage friend and foe independently.
Hope that helps.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.