Trying to add "/app/stop" and "/app/ping"

Hello everyone,

I am trying to add two pages to bokeh application: one to stop the server (GET to /app/stop), and one to check the server health (GET to /app/ping responds pong).

Currently I am working on implementing solution by embedding bokeh server into tornado, but that is fairly verbose way and maybe I am missing something. Can someone can suggest simpler approach?

With best regards,

Timur.

Hi Timur,

Have you looked at the example at https://github.com/bokeh/bokeh/blob/0.12.10/examples/howto/server_embed/tornado_embed.py ?

It doesn’t look that verbose - the only code that’s not relevant to plotting itself is IndexHandler and five lines to create Bokeh Application and Server and to start the server.

And to add “/app/stop” and “/app/ping” endpoints, you just have to implement two RequestHandlers - just like the IndexHandler in the example.

Regards,

Eugene

···

On Monday, November 13, 2017 at 7:39:38 PM UTC+7, Timur Zaripov wrote:

Hello everyone,

I am trying to add two pages to bokeh application: one to stop the server (GET to /app/stop), and one to check the server health (GET to /app/ping responds pong).

Currently I am working on implementing solution by embedding bokeh server into tornado, but that is fairly verbose way and maybe I am missing something. Can someone can suggest simpler approach?

With best regards,

Timur.

Hi Eugene,

I have seen that example, but couldn’t make it work with my application initially, and was trying to modify https://gist.github.com/Sklavit/c378a18661f0d91918931eba5a1d7553

After your message I made another attempt and finally figured out what was wrong with application path and it works now. The issue was in the way tornado and bokeh serve deal with prefix.

Thank you for the swift response and suggestion! I will manage it from this point.

With best regards,

Timur.

···

On Monday, 13 November 2017 15:51:02 UTC+3, Eugene Pakhomov wrote:

Hi Timur,

Have you looked at the example at https://github.com/bokeh/bokeh/blob/0.12.10/examples/howto/server_embed/tornado_embed.py ?

It doesn’t look that verbose - the only code that’s not relevant to plotting itself is IndexHandler and five lines to create Bokeh Application and Server and to start the server.

And to add “/app/stop” and “/app/ping” endpoints, you just have to implement two RequestHandlers - just like the IndexHandler in the example.

Regards,

Eugene

On Monday, November 13, 2017 at 7:39:38 PM UTC+7, Timur Zaripov wrote:

Hello everyone,

I am trying to add two pages to bokeh application: one to stop the server (GET to /app/stop), and one to check the server health (GET to /app/ping responds pong).

Currently I am working on implementing solution by embedding bokeh server into tornado, but that is fairly verbose way and maybe I am missing something. Can someone can suggest simpler approach?

With best regards,

Timur.

class StopHandler(RequestHandler):

def get(self):

server.io_loop.stop()

server = Server(

{

‘/bkapp’: bokeh_app

}, num_procs=1,

extra_patterns=[

(‘/’, IndexHandler),

(‘/stop’, StopHandler),

])

server.start()

if name == ‘main’:

from bokeh.util.browser import view

     server.io_loop.add_callback(view, "http://localhost:5006/")

server.io_loop.start()

``

How would I stop server.io_loop, when num_proc>1?

With best regards,
Timur.

···

On Monday, 13 November 2017 16:17:27 UTC+3, Timur Zaripov wrote:

Hi Eugene,

I have seen that example, but couldn’t make it work with my application initially, and was trying to modify https://gist.github.com/Sklavit/c378a18661f0d91918931eba5a1d7553

After your message I made another attempt and finally figured out what was wrong with application path and it works now. The issue was in the way tornado and bokeh serve deal with prefix.

Thank you for the swift response and suggestion! I will manage it from this point.

With best regards,

Timur.

On Monday, 13 November 2017 15:51:02 UTC+3, Eugene Pakhomov wrote:

Hi Timur,

Have you looked at the example at https://github.com/bokeh/bokeh/blob/0.12.10/examples/howto/server_embed/tornado_embed.py ?

It doesn’t look that verbose - the only code that’s not relevant to plotting itself is IndexHandler and five lines to create Bokeh Application and Server and to start the server.

And to add “/app/stop” and “/app/ping” endpoints, you just have to implement two RequestHandlers - just like the IndexHandler in the example.

Regards,

Eugene

On Monday, November 13, 2017 at 7:39:38 PM UTC+7, Timur Zaripov wrote:

Hello everyone,

I am trying to add two pages to bokeh application: one to stop the server (GET to /app/stop), and one to check the server health (GET to /app/ping responds pong).

Currently I am working on implementing solution by embedding bokeh server into tornado, but that is fairly verbose way and maybe I am missing something. Can someone can suggest simpler approach?

With best regards,

Timur.