A headless non-interactive JSServe and WGLMakie server?

I have a JSServe+WGLMakie visualization that works wonderfully when launched from the REPL. It is basically little more than:

app = App do()
    dom = md"test" # and some plots that I deleted
    return JSServe.DOM.div(JSServe.MarkdownCSS, JSServe.Styling, dom)

Now that everything is polished, I want to run it from a headless server. I put it in a file, I added JSServe.route!(JSServe.get_server(), "/" => app) at the bottom and I launched it with julia my_wglmakie_server.jl. This script immediately exits instead of blocking/waiting on the server event loop. If I do julia -i my_wglmakie_server.jl it works fine because -i makes julia go in interactive mode after the server is launched and it just waits on user input (while serving in the background).

I suspect I am doing something incredibly silly and wrong… My question is, how do it make this script not quit without using interactive julia -i? I was expecting some call like wait(server) or block(server) or serve() or server_event_loop() that blocks the script so that it does not quit. All similar python libraries I have used employ that style (calling a function that blocks the script and runs the sever event loop).

you should be able to do:


Check this example out as well:

Maybe that should contain the wait trick, or server should just overload Base.wait(server::Server)

1 Like

@sdanisch, thank you, this is exactly what I needed.

I turned your suggestion into a pull request: add Base.wait(::Server) by Krastanov · Pull Request #135 · SimonDanisch/JSServe.jl · GitHub
Could you consider it for inclusion?

1 Like