module PackageFoo
using Observables
using Observables: to_value, AbstractObservable
using JSServe
using JSServe: evaljs, onjs, onload, Table, Server
import Tables
import JSServe: jsrender
using JSServe, WGLMakie
using GeometryBasics
using FileIO
using JSServe: @js_str, onjs, App, Slider
using JSServe.DOM
import JSServe.TailwindDashboard as D
const SERVER = Ref{Any}(nothing)
function main(; port::Int=4269, hold=true, verbose=false)
SERVER[] isa Server && close(SERVER[])
app = App() do session::Session
s1 = Slider(1:100)
s2 = Slider(1:100)
b = Button("hi")
t = TextField("enter your text")
s_value = s1.value
linkjs(session, s1.value, s2.value)
test = [1, 2, 3]
onjs(session, s1.value, js"(v)=> console.log(v + ' ' + $(test))")
on(t) do text
println(text)
end
return DOM.div(s1, s2, b, t)
end
SERVER[] = Server(app, "127.0.0.1", port; verbose)
# hold && browser("http://localhost:$port")
hold && wait(SERVER[])
end
If I add an examples/serve.jl with the following code:
using PackageFoo
PackageFoo.main()
And run it and Ctrl + C, I don't get any error.
However, if I run it from the command line like
julia --project -e "using PackageFoo; PackageFoo.main()"
or if I open a julia REPL and run the using PackageFoo; PackageFoo.main(); then it still runs fine however when I hit Ctrl + C I get a segfault sometimes and I get an error other times.
I relatively sure that this is a HTTP/Julia issue.
Could be wrong, but the stacktrace certainly points to it.
You can call close(server) so maybe you can do some different wait loop than wait(SERVER)?
I have a Package with the following code:
If I add an
examples/serve.jl
with the following code:And run it and
Ctrl + C
, I don't get any error.However, if I run it from the command line like
or if I open a julia REPL and run the
using PackageFoo; PackageFoo.main()
; then it still runs fine however when I hitCtrl + C
I get a segfault sometimes and I get an error other times.Here's the error:
I'm not able to reproduce the segfault at the moment but I can update this issue with the segfault stacktrace when I do.
Is this expected?