-
Notifications
You must be signed in to change notification settings - Fork 180
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add an offline precompile workload (#1195)
* add an offline precompile workload * suggestions * fix * tweak inits * precompile https * only run workload if precompiling pkgimages * Update src/precompile.jl * Revert "Update src/precompile.jl" This reverts commit cb9b1f2. * precompile wheter or not pkgimages are used --------- Co-authored-by: Jacob Quinn <quinn.jacobd@gmail.com>
- Loading branch information
1 parent
f44242e
commit 6aa6981
Showing
3 changed files
with
47 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using PrecompileTools: @setup_workload, @compile_workload | ||
|
||
@setup_workload begin | ||
# These need to be safe to call here and bake into the pkgimage, i.e. called twice. | ||
Connections.__init__() | ||
MultiPartParsing.__init__() | ||
Parsers.__init__() | ||
|
||
# Doesn't seem to be needed here, and might not be safe to call twice (here and during runtime) | ||
# ConnectionRequest.__init__() | ||
|
||
gzip_data(data::String) = read(GzipCompressorStream(IOBuffer(data))) | ||
|
||
# random port in the dynamic/private range (49152–65535) which are are | ||
# least likely to be used by well-known services | ||
_port = 57813 | ||
|
||
cert, key = joinpath.(@__DIR__, "../test", "resources", ("cert.pem", "key.pem")) | ||
sslconfig = MbedTLS.SSLConfig(cert, key) | ||
|
||
server = HTTP.serve!("0.0.0.0", _port; verbose = -1, listenany=true, sslconfig=sslconfig) do req | ||
HTTP.Response(200, ["Content-Encoding" => "gzip"], gzip_data("dummy response")) | ||
end | ||
# listenany allows changing port if that one is already in use, so check the actual port | ||
_port = HTTP.port(server) | ||
url = "https://localhost:$_port" | ||
|
||
env = ["JULIA_NO_VERIFY_HOSTS" => "localhost", | ||
"JULIA_SSL_NO_VERIFY_HOSTS" => nothing, | ||
"JULIA_ALWAYS_VERIFY_HOSTS" => nothing] | ||
withenv(env...) do | ||
@compile_workload begin | ||
HTTP.get(url); | ||
end | ||
end | ||
|
||
HTTP.forceclose(server) | ||
server = nothing | ||
end |