Starting a bokeh serve process when someone visits

I managed to keep a bokeh app running on a server, by opening a screen on that server and starting a process with bokeh serve. I also required a custom apache configuration as detailed here.

Keeping the bokeh serve instance up works, but it feels clunky, and the bokeh process running on it is always working hard, which makes our sysadmin suspicious and unhappy (I also have no idea why it does that). Is there some other way to do it, e.g. by having some kind of watcher that spins up a process when someone visits? Heroku seems able to do it, but I don’t know how.

It’s certainly possible in principle, but that kind of infrastructure orchestration is well outside the scope of the Bokeh project itself. The Bokeh server is just that—a server—and like pretty much any (web) server, it has to be running to function. This is really no different that a Flask web app or a JupyterHub instance, or any other kind of server waiting for users to connect.

If you don’t actually need to run real Python code then you could look at creating standalone Bokeh output, which is just plain HTML and JavaScript, so no Bokeh server is needed. You can still have many kinds of interactivity with e.g. CustomJS callbacks. If your use case requires triggering real Python callbacks, then that’s the main use case for a Bokeh server app.