From 2c4d1d21fad7a2f036953f26d62f00f5363a6110 Mon Sep 17 00:00:00 2001 From: gearsad Date: Tue, 27 Nov 2018 00:07:05 -0600 Subject: [PATCH 1/2] Adding server:host parameter and setting to default 0.0.0.0 --- src/Commands.jl | 9 ++++++++- src/Configuration.jl | 5 ++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Commands.jl b/src/Commands.jl index 097f95513..651f7a398 100755 --- a/src/Commands.jl +++ b/src/Commands.jl @@ -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 @@ -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) diff --git a/src/Configuration.jl b/src/Configuration.jl index c7901c640..241f9f8da 100755 --- a/src/Configuration.jl +++ b/src/Configuration.jl @@ -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 @@ -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, @@ -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, From ad4b2fa045972610012453a5fa1b85b6ccfbc654 Mon Sep 17 00:00:00 2001 From: gearsad Date: Tue, 27 Nov 2018 00:10:57 -0600 Subject: [PATCH 2/2] Removing test message --- src/Commands.jl | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Commands.jl b/src/Commands.jl index 651f7a398..6f9b2e7a4 100755 --- a/src/Commands.jl +++ b/src/Commands.jl @@ -16,7 +16,6 @@ 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