# A headless non-interactive JSServe and WGLMakie server?

**URL:** https://discourse.julialang.org/t/a-headless-non-interactive-jsserve-and-wglmakie-server/90549
**Category:** Visualization
**Tags:** wglmakie, jsserve
**Created:** [November 20, 2022, 6:08pm UTC](https://discourse.julialang.org/t/a-headless-non-interactive-jsserve-and-wglmakie-server/90549 "2022-11-20T18:08:27Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Krastanov](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/krastanov/32/6817_2.png) [@Krastanov](https://discourse.julialang.org/u/Krastanov)
#### Post date: [November 20, 2022, 6:08pm UTC](https://discourse.julialang.org/t/a-headless-non-interactive-jsserve-and-wglmakie-server/90549/1 "2022-11-20T18:08:27Z")

</div>

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

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

```

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).

---

<div class="post-metadata">

### Author: ![sdanisch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sdanisch/32/1406_2.png) [@sdanisch](https://discourse.julialang.org/u/sdanisch)
#### Post date: [November 21, 2022, 11:58am UTC](https://discourse.julialang.org/t/a-headless-non-interactive-jsserve-and-wglmakie-server/90549/2 "2022-11-21T11:58:52Z")

</div>

you should be able to do:

```julia
wait(server.server_task[])

```

Check this example out as well:

> <https://github.com/SimonDanisch/JSServe.jl/blob/master/examples/serve.jl>

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

---

<div class="post-metadata">

### Author: ![Krastanov](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/krastanov/32/6817_2.png) [@Krastanov](https://discourse.julialang.org/u/Krastanov)
#### Post date: [November 21, 2022, 2:18pm UTC](https://discourse.julialang.org/t/a-headless-non-interactive-jsserve-and-wglmakie-server/90549/3 "2022-11-21T14:18:51Z")

</div>

@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](https://github.com/SimonDanisch/JSServe.jl/pull/135)  
Could you consider it for inclusion?
