How to start two processes in Procfile?

I have a Flask application in which I have embedded the Bokeh server graph and I cannot get them to work on Heroku. I'm trying to deploy to Heorku, and I can either run the Bokeh application or the Flask application from Procfile, but not both at the same time. Therefore, either the content contained with Flask will be displayed, or the Bokeh graph.

When I deploy the following line to a Procfile, the Bokeh content appears on the web page, but not from nothing from Flask:

web: bokeh serve --port=$PORT --host=bokehapp.herokuapp.com --host=* --address=0.0.0.0 --use-xheaders bokeh_script.py

If I expand with the following, I get the contents of Flask, not the Bokeh graph:

web: gunicorn app:app

In the second case, I run Bokeh inside the app.py Flask script using a subprocess:

bokeh_process = subprocess.Popen(
    ['bokeh', 'serve','--allow-websocket-origin=bokehapp.herokuapp.com','--log-level=debug','standard_way_with_curdoc.py'], stdout=subprocess.PIPE)

Heroku logs show no errors.

I also tried the third option:

web: bokeh serve --port=$PORT --host=bokehapp.herokuapp.com --host=* --address=0.0.0.0 --use-xheaders bokeh_script.py
web: gunicorn app:app

And this shows only the contents of the flask. It seems that only the second worker is being considered.

, , Procfile ? , , ? , , .

+4
1

Heroku , $PORT, Heroku . , -, dyno.

, , , - Flask. , /bokeh/<path:path> -, bokeh requests, . -, bokeh .

, Flask Heroku , bokeh. - , bokeh.

- . Flask , bokeh, URL- bokeh.

, , , , , , . , , ,

+5

Source: https://habr.com/ru/post/1655489/


All Articles