Skip to content

Commit

Permalink
Auto-start server (run_as_server) if EARLYBIND is "true" and "STARTSE…
Browse files Browse the repository at this point in the history
…RVER" is not "false"
  • Loading branch information
essenciary committed Sep 25, 2023
1 parent 47e81df commit e894796
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Genie"
uuid = "c43c736e-a2d1-11e8-161f-af95117fbd1e"
authors = ["Adrian Salceanu <[email protected]>"]
version = "5.18.2"
version = "5.19.0"

[deps]
ArgParse = "c7e460c6-2fb9-53a9-8c5b-16f535851c63"
Expand Down
11 changes: 6 additions & 5 deletions src/Commands.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,16 @@ function execute(config::Genie.Configuration.Settings; server::Union{Sockets.TCP

# overwrite env settings with command line arguments
Genie.config.server_port = parse(Int, parsed_args["p"])
Genie.config.websockets_port = parsed_args["w"] == "nothing" ? nothing : parse(Int, parsed_args["w"])
Genie.config.websockets_port = lowercase(parsed_args["w"]) == "nothing" ? nothing : parse(Int, parsed_args["w"])
Genie.config.server_host = parsed_args["l"]
Genie.config.websockets_exposed_host = parsed_args["x"] == "nothing" ? nothing : parsed_args["x"]
Genie.config.websockets_exposed_port = parsed_args["y"] == "nothing" ? nothing : parse(Int, parsed_args["y"])
Genie.config.websockets_exposed_host = lowercase(parsed_args["x"]) == "nothing" ? nothing : parsed_args["x"]
Genie.config.websockets_exposed_port = lowercase(parsed_args["y"]) == "nothing" ? nothing : parse(Int, parsed_args["y"])
Genie.config.websockets_base_path = parsed_args["W"]
Genie.config.base_path = parsed_args["b"]

if (called_command(parsed_args, "s") && get(parsed_args, "s", "false") == "true") ||
(haskey(ENV, "STARTSERVER") && parse(Bool, ENV["STARTSERVER"]))
if (called_command(parsed_args, "s") && lowercase(get(parsed_args, "s", "false")) == "true") ||
(haskey(ENV, "STARTSERVER") && parse(Bool, ENV["STARTSERVER"])) ||
(haskey(ENV, "EARLYBIND") && lowercase(get(ENV, "STARTSERVER", "")) != "false")
Genie.config.run_as_server = true
Base.invokelatest(Genie.up, Genie.config.server_port, Genie.config.server_host; server = server)

Expand Down
5 changes: 4 additions & 1 deletion src/Genie.jl
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,10 @@ julia> Genie.loadapp(".")
[ Info: Logging to file at MyGenieApp/log/dev.log
```
"""
function loadapp(path::String = "."; autostart::Bool = false, dbadapter::Union{Nothing,Symbol,String} = nothing, context = Main) :: Nothing
function loadapp( path::String = ".";
autostart::Bool = false,
dbadapter::Union{Nothing,Symbol,String} = nothing,
context = Main) :: Nothing
if ! isnothing(dbadapter) && dbadapter != "nothing"
Genie.Generator.autoconfdb(dbadapter)
end
Expand Down
4 changes: 2 additions & 2 deletions src/Loader.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function importenv()
end


function loadenv(; context)
function loadenv(; context) :: Union{Sockets.TCPServer,Nothing}
haskey(ENV, "GENIE_ENV") || (ENV["GENIE_ENV"] = "dev")
bootstrap(context)

Expand Down Expand Up @@ -262,7 +262,7 @@ function sort_load_order(rootdir, lsdir::Vector{String})
autoloadfilepath = isfile(joinpath(pwd(), rootdir, Genie.config.autoload_file)) ? joinpath(pwd(), rootdir, Genie.config.autoload_file) : return lsdir
autoloadorder = open(f -> ([line for line in eachline(f)]), autoloadfilepath)
fn_loadorder = []

for file in autoloadorder
if file in lsdir
push!(fn_loadorder, file)
Expand Down

0 comments on commit e894796

Please sign in to comment.