From 5d6ca1498e8c1943b331d2c7fa43e7a6cc8c85da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Thu, 7 Apr 2016 11:06:49 +0200 Subject: [PATCH] CLI options to run webapp server --- parity/main.rs | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/parity/main.rs b/parity/main.rs index 2141a5795..ecd72e0ff 100644 --- a/parity/main.rs +++ b/parity/main.rs @@ -120,7 +120,7 @@ Networking Options: string or input to SHA3 operation. API and Console Options: - -j --jsonrpc Enable the JSON-RPC API sever. + -j --jsonrpc Enable the JSON-RPC API server. --jsonrpc-interface IP Specify the hostname portion of the JSONRPC API server, IP should be an interface's IP address, or all (all interfaces) or local [default: local]. @@ -132,6 +132,10 @@ API and Console Options: interface. APIS is a comma-delimited list of API name. Possible name are web3, eth and net. [default: web3,eth,net,personal]. + -w --webap Enable the web applications server (e.g. status page). + --webapp-port PORT Specify the port portion of the WebApps server + [default: 8080]. + Sealing/Mining Options: --usd-per-tx USD Amount of USD to be paid for a basic transaction @@ -216,6 +220,8 @@ struct Args { flag_jsonrpc_port: u16, flag_jsonrpc_cors: String, flag_jsonrpc_apis: String, + flag_webapp: bool, + flag_webapp_port: u16, flag_author: String, flag_usd_per_tx: String, flag_usd_per_eth: String, @@ -295,6 +301,13 @@ fn setup_rpc_server( } Some(server.start_http(url, cors_domain, ::num_cpus::get())) } +#[cfg(feature = "webapp")] +fn setup_webapp_server( + url: &str +) -> Option> { + let server = webapp::WebappServer::new(); + Some(server.start_http(url, ::num_cpus::get())) +} #[cfg(not(feature = "rpc"))] fn setup_rpc_server( @@ -309,6 +322,13 @@ fn setup_rpc_server( None } +#[cfg(not(feature = "webapp"))] +fn setup_webapp_server( + _url: &str +) -> Option> { + None +} + fn print_version() { println!("\ Parity @@ -611,6 +631,15 @@ impl Configuration { } } + if self.args.flag_webapp { + let url = format!("0.0.0.0:{}", self.args.flag_webapp_port); + setup_webapp_server( + &url, + ).map(|handler| { + panic_handler.forward_from(handler.deref()); + }); + } + // Register IO handler let io_handler = Arc::new(ClientIoHandler { client: service.client(),