Skip to content

Commit

Permalink
Adding server:host parameter and setting to default 0.0.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
GearsAD committed Nov 27, 2018
1 parent 7ec7095 commit 2c4d1d2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/Commands.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@ function execute(config::Settings) :: Nothing

Genie.config.app_env = ENV["GENIE_ENV"]
Genie.config.server_port = parse(Int, parsed_args["server:port"])
if haskey(parsed_args, "server:host") && parsed_args["server:host"] != nothing
@show "haskey1"
Genie.config.server_host = parsed_args["server:host"]
end

if called_command(parsed_args, "s") || called_command(parsed_args, "server:start")
Genie.config.run_as_server = true
AppServer.startup(Genie.config.server_port)
AppServer.startup(Genie.config.server_port, Genie.config.server_host)
end

nothing
Expand Down Expand Up @@ -47,6 +51,9 @@ function parse_commandline_args() :: Dict{String,Any}
"--server:port", "-p"
help = "HTTP server port"
default = "8000"
"--server:host", "-l"
help = "Host IP to listen on"
# default = "" #This is by default open (0.0.0.0), set to 127.0.0.1 for only localhost
end

parse_args(settings)
Expand Down
5 changes: 4 additions & 1 deletion src/Configuration.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ App configuration - sets up the app's defaults. Individual options are overwritt
"""
mutable struct Settings
server_port::Int
server_host::String
server_workers_count::Int
server_document_root::String
server_handle_static_files::Bool
Expand Down Expand Up @@ -131,6 +132,7 @@ mutable struct Settings

Settings(;
server_port = 8000, # default port for binding the web server
server_host = "0.0.0.0",
server_workers_count = 1,
server_document_root = "public",
server_handle_static_files = true,
Expand Down Expand Up @@ -196,7 +198,8 @@ mutable struct Settings
renderer_default_layout_file = :app,
) =
new(
server_port, server_workers_count, server_document_root, server_handle_static_files, server_signature,
server_port, server_host,
server_workers_count, server_document_root, server_handle_static_files, server_signature,
app_env,
cors_headers, cors_allowed_origins,
suppress_output, output_length,
Expand Down

0 comments on commit 2c4d1d2

Please sign in to comment.