Closed SimonDanisch closed 1 week ago
@bjarthur can you test if this fixes your example?
sadly it's still broken:
ArgumentError: not a path: `/opt/t4d/.julia/dev/Smiley/smiley.png` Stacktrace: [1] RelocatableFolders.Path(mod::Module, dir::String, path::String, ignore::Nothing) @ RelocatableFolders /opt/t4d/.julia/packages/RelocatableFolders/URtlI/src/RelocatableFolders.jl:55 [2] (::Smiley.var"#3#5")() @ Smiley /opt/t4d/.julia/dev/Smiley/src/Smiley.jl:49 [3] (::Bonito.var"#10#16"{Smiley.var"#3#5"})(session::Bonito.Session{Bonito.WebSocketConnection}, request::HTTP.Messages.Request) @ Bonito /opt/t4d/.julia/dev/Bonito/src/types.jl:330 [4] #invokelatest#2 @ ./essentials.jl:892 [inlined] [5] invokelatest @ ./essentials.jl:889 [inlined] [6] rendered_dom(session::Bonito.Session{Bonito.WebSocketConnection}, app::Bonito.App, target::HTTP.Messages.Request) @ Bonito /opt/t4d/.julia/dev/Bonito/src/app.jl:40 [7] serve_app(app::Bonito.App, context::@NamedTuple{routes::Bonito.HTTPServer.Routes, application::Bonito.HTTPServer.Server, request::HTTP.Messages.Request, match::String}) @ Bonito /opt/t4d/.julia/dev/Bonito/src/app.jl:57 [8] apply_handler(app::Bonito.App, context::@NamedTuple{routes::Bonito.HTTPServer.Routes, application::Bonito.HTTPServer.Server, request::HTTP.Messages.Request, match::String}) @ Bonito /opt/t4d/.julia/dev/Bonito/src/app.jl:72 [9] delegate(::Bonito.HTTPServer.Routes, ::Bonito.HTTPServer.Server, ::HTTP.Messages.Request) @ Bonito.HTTPServer /opt/t4d/.julia/dev/Bonito/src/HTTPServer/implementation.jl:102 [10] #18 @ /opt/t4d/.julia/dev/Bonito/src/HTTPServer/implementation.jl:169 [inlined] [11] (::HTTP.Handlers.var"#1#2"{Bonito.HTTPServer.var"#18#20"{Bonito.HTTPServer.Server}})(stream::HTTP.Streams.Stream{HTTP.Messages.Request, HTTP.Connections.Connection{MbedTLS.SSLContext}}) @ HTTP.Handlers /opt/t4d/.julia/packages/HTTP/sJD5V/src/Handlers.jl:58 [12] stream_handler(application::Bonito.HTTPServer.Server, stream::HTTP.Streams.Stream{HTTP.Messages.Request, HTTP.Connections.Connection{MbedTLS.SSLContext}}) @ Bonito.HTTPServer /opt/t4d/.julia/dev/Bonito/src/HTTPServer/implementation.jl:174 [13] #invokelatest#2 @ ./essentials.jl:892 [inlined] [14] invokelatest @ ./essentials.jl:889 [inlined] [15] (::Bonito.HTTPServer.var"#27#29"{Bonito.HTTPServer.Server})(stream::HTTP.Streams.Stream{HTTP.Messages.Request, HTTP.Connections.Connection{MbedTLS.SSLContext}}) @ Bonito.HTTPServer /opt/t4d/.julia/dev/Bonito/src/HTTPServer/implementation.jl:287 [16] #invokelatest#2 @ ./essentials.jl:892 [inlined] [17] invokelatest @ ./essentials.jl:889 [inlined] [18] handle_connection(f::Function, c::HTTP.Connections.Connection{MbedTLS.SSLContext}, listener::HTTP.Servers.Listener{MbedTLS.SSLConfig, Sockets.TCPServer}, readtimeout::Int64, access_log::Nothing) @ HTTP.Servers /opt/t4d/.julia/packages/HTTP/sJD5V/src/Servers.jl:469 [19] (::HTTP.Servers.var"#16#17"{Bonito.HTTPServer.var"#27#29"{Bonito.HTTPServer.Server}, HTTP.Servers.Listener{MbedTLS.SSLConfig, Sockets.TCPServer}, Set{HTTP.Connections.Connection}, Int64, Nothing, ReentrantLock, Base.Semaphore, HTTP.Connections.Connection{MbedTLS.SSLContext}})() @ HTTP.Servers /opt/t4d/.julia/packages/HTTP/sJD5V/src/Servers.jl:401
full module code i used is:
module Smiley
using WGLMakie, Bonito, RelocatableFolders, Markdown, MbedTLS
function julia_main()::Cint
kwargs = Dict{Symbol,Any}()
kwargs[:url] = ARGS[1]
kwargs[:port] = parse(Int64, ARGS[2])
server = smiley(; kwargs...)
while !istaskdone(server.server_task[])
flush(stdout)
flush(stderr)
sleep(10)
end
return 0
end
function smiley(; url, port)
main = App() do
WGLMakie.activate!()
dom = md"""
[smiley](/smiley)
"""
return DOM.div(Bonito.MarkdownCSS, Bonito.Styling, dom)
end
smiley = App() do
DOM.div(DOM.img(src=Asset(@path joinpath(dirname(@__DIR__),"smiley.png"))))
end
server = Bonito.Server(main, url, port, verbose=true,
sslconfig=MbedTLS.SSLConfig("/etc/http/ssl/full.crt",
"/etc/http/ssl/key"))
route!(server, "/smiley" => smiley)
show(server)
return server
end
end
and in test/runtests.jl:
using Smiley
Smiley.smiley(url="<my-machine.my-comany.com>", port=443)
i compiled with create_app(".", "../SmileyCompiled", precompile_execution_file = "test/runtests.jl")
, made sure it worked on the same machine with SmileyCompiled/bin/Smiley my-machine.my-comany.com 443
, rsync'ed SmileyCompiled
to another machine, executed on that machine SmileyCompiled/bin/Smiley my-other-machine.my-comany.com 443
, and when i click on the resulting "smiley" link i get the above error.
thanks for trying! i will keep looking into it...
actually, this PR works for me! problem was that in my test above the @path
wasn't being compiled ahead of time. refactoring it so that it was at the top-level of the module was all that i needed to do:
module Smiley
<SNIP>
REPO = @path dirname(@__DIR__)
smiley_png = @path joinpath(REPO, "smiley.png")
<SNIP>
end # module
the only change that might be needed for this PR is to add another @path
to bundle_dir
here.
would be great if this PR and the corresponding relocatability PR in Makie could be reviewed again. thanks so much!
Continuation of #227