python - How do I run two processes in Procfile? -


i have flask app have embedded bokeh server graph , not being able have them both working on heroku. trying deploy on heorku , can either start bokeh app or flask app procfile, not both @ same time. consequently, either content served flask show, or bokeh graph.

when deploy following line in procfile, bokeh content shows on webpage, not nothing flask:

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

if deploy following, flask content, not bokeh graph:

web: gunicorn app:app 

in second case, starting bokeh inside app.py flask script using subprocess:

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

the heroku logs don't show errors.

i tried third alternative:

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 shows flask content only. seems second worker being considered.

so, question how modify procfile consider both processes? or maybe approaching wrong together? clue can give appreciated.

each heroku dyno gets allocated single public network port, can $port variable, pre-assigned heroku before launching app. unfortunate side effect of can have 1 public web server running in dyno.

i think first thing need route requests application through flask server. example, can add /bokeh/<path:path> route flask app forwards requests bokeh server using requests, sends response client. change, have single public web server, , bokeh server can run background service without public access.

so can deploy flask app heroku, , have receive both own requests , requests bokeh server. next step figure out deploy bokeh server.

the proper way deploy bokeh on separate dyno. flask dyno know how forward requests bokeh because have configuration item bokeh server url.

if want have hosted on single dyno think can well, though have never tried myself , can't confirm viable. in 1 configuration less ideal , not heroku recommends, according dyno networking documentation appears can privately listen on network ports besides $port. not exposed publicly, doc seems suggest processes running inside dyno can communicate through private ports. example, can start flask app on $port, , bokeh server on $port + 1, , have flask internally forward bokeh requests $port + 1.


Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -