Windows build (#1253)
* Networking refactoring * Fixed typo * Trace logging * Updated dependencies for windows build * Windows fixes * use mio 0.5 * nix build * Windows build fix * style * removed unused import * ipc crate version bump * ipc config for named pipes * tweaks and fixes * tweaks and fixes * final version bump * Fixed tests * Disable color output on windows * Added missing doc
This commit is contained in:
committed by
Gav Wood
parent
4ef4819bf9
commit
6b12334136
@@ -287,9 +287,14 @@ impl Configuration {
|
||||
}
|
||||
|
||||
fn geth_ipc_path(&self) -> String {
|
||||
if self.args.flag_testnet { path::ethereum::with_testnet("geth.ipc") }
|
||||
else { path::ethereum::with_default("geth.ipc") }
|
||||
.to_str().unwrap().to_owned()
|
||||
if cfg!(windows) {
|
||||
r"\\.\pipe\geth.ipc".to_owned()
|
||||
}
|
||||
else {
|
||||
if self.args.flag_testnet { path::ethereum::with_testnet("geth.ipc") }
|
||||
else { path::ethereum::with_default("geth.ipc") }
|
||||
.to_str().unwrap().to_owned()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn keys_iterations(&self) -> u32 {
|
||||
@@ -358,7 +363,18 @@ impl Configuration {
|
||||
|
||||
fn ipc_path(&self) -> String {
|
||||
if self.args.flag_geth { self.geth_ipc_path() }
|
||||
else { Configuration::replace_home(&self.args.flag_ipcpath.clone().unwrap_or(self.args.flag_ipc_path.clone())) }
|
||||
else {
|
||||
if cfg!(windows) {
|
||||
r"\\.\pipe\parity.jsonrpc".to_owned()
|
||||
}
|
||||
else {
|
||||
Configuration::replace_home(&self.args.flag_ipcpath.clone().unwrap_or(self.args.flag_ipc_path.clone()))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn have_color(&self) -> bool {
|
||||
!self.args.flag_no_color && !cfg!(windows)
|
||||
}
|
||||
|
||||
pub fn signer_port(&self) -> Option<u16> {
|
||||
|
||||
@@ -32,6 +32,7 @@ extern crate log as rlog;
|
||||
extern crate env_logger;
|
||||
extern crate ctrlc;
|
||||
extern crate fdlimit;
|
||||
#[cfg(not(windows))]
|
||||
extern crate daemonize;
|
||||
extern crate time;
|
||||
extern crate number_prefix;
|
||||
@@ -86,7 +87,6 @@ use ethcore::service::ClientService;
|
||||
use ethcore::spec::Spec;
|
||||
use ethsync::EthSync;
|
||||
use ethcore::miner::{Miner, MinerService, ExternalMiner};
|
||||
use daemonize::Daemonize;
|
||||
use migration::migrate;
|
||||
use informant::Informant;
|
||||
|
||||
@@ -115,11 +115,7 @@ fn execute(conf: Configuration) {
|
||||
execute_upgrades(&conf, &spec, &client_config);
|
||||
|
||||
if conf.args.cmd_daemon {
|
||||
Daemonize::new()
|
||||
.pid_file(conf.args.arg_pid_file.clone())
|
||||
.chown_pid_file(true)
|
||||
.start()
|
||||
.unwrap_or_else(|e| die!("Couldn't daemonize; {}", e));
|
||||
daemonize(&conf);
|
||||
}
|
||||
|
||||
if conf.args.cmd_account {
|
||||
@@ -145,6 +141,20 @@ fn execute(conf: Configuration) {
|
||||
execute_client(conf, spec, client_config);
|
||||
}
|
||||
|
||||
#[cfg(not(windows))]
|
||||
fn daemonize(conf: &Configuration) {
|
||||
use daemonize::Daemonize;
|
||||
Daemonize::new()
|
||||
.pid_file(conf.args.arg_pid_file.clone())
|
||||
.chown_pid_file(true)
|
||||
.start()
|
||||
.unwrap_or_else(|e| die!("Couldn't daemonize; {}", e));
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
fn daemonize(_conf: &Configuration) {
|
||||
}
|
||||
|
||||
fn execute_upgrades(conf: &Configuration, spec: &Spec, client_config: &ClientConfig) {
|
||||
match ::upgrade::upgrade(Some(&conf.path())) {
|
||||
Ok(upgrades_applied) if upgrades_applied > 0 => {
|
||||
@@ -228,6 +238,7 @@ fn execute_client(conf: Configuration, spec: Spec, client_config: ClientConfig)
|
||||
|
||||
// setup ipc rpc
|
||||
let _ipc_server = rpc::new_ipc(conf.ipc_settings(), &dependencies);
|
||||
debug!("IPC: {}", conf.ipc_settings());
|
||||
|
||||
if conf.args.flag_webapp { println!("WARNING: Flag -w/--webapp is deprecated. Dapps server is now on by default. Ignoring."); }
|
||||
let dapps_server = dapps::new(dapps::Configuration {
|
||||
@@ -255,7 +266,7 @@ fn execute_client(conf: Configuration, spec: Spec, client_config: ClientConfig)
|
||||
// Register IO handler
|
||||
let io_handler = Arc::new(ClientIoHandler {
|
||||
client: service.client(),
|
||||
info: Informant::new(!conf.args.flag_no_color),
|
||||
info: Informant::new(conf.have_color()),
|
||||
sync: sync.clone(),
|
||||
accounts: account_service.clone(),
|
||||
});
|
||||
@@ -375,8 +386,8 @@ fn execute_import(conf: Configuration) {
|
||||
panic_handler.forward_from(&service);
|
||||
let client = service.client();
|
||||
|
||||
let mut instream: Box<Read> = if let Some(f) = conf.args.arg_file {
|
||||
let f = File::open(&f).unwrap_or_else(|_| die!("Cannot open the file given: {}", f));
|
||||
let mut instream: Box<Read> = if let Some(ref f) = conf.args.arg_file {
|
||||
let f = File::open(f).unwrap_or_else(|_| die!("Cannot open the file given: {}", f));
|
||||
Box::new(f)
|
||||
} else {
|
||||
Box::new(::std::io::stdin())
|
||||
@@ -386,7 +397,7 @@ fn execute_import(conf: Configuration) {
|
||||
let mut first_read = 0;
|
||||
|
||||
let format = match conf.args.flag_format {
|
||||
Some(x) => match x.deref() {
|
||||
Some(ref x) => match x.deref() {
|
||||
"binary" | "bin" => DataFormat::Binary,
|
||||
"hex" => DataFormat::Hex,
|
||||
x => die!("Invalid --format parameter given: {:?}", x),
|
||||
@@ -407,7 +418,7 @@ fn execute_import(conf: Configuration) {
|
||||
}
|
||||
};
|
||||
|
||||
let informant = Informant::new(!conf.args.flag_no_color);
|
||||
let informant = Informant::new(conf.have_color());
|
||||
|
||||
let do_import = |bytes| {
|
||||
while client.queue_info().is_full() { sleep(Duration::from_secs(1)); }
|
||||
|
||||
@@ -22,6 +22,7 @@ use util::panics::PanicHandler;
|
||||
use die::*;
|
||||
use jsonipc;
|
||||
use rpc_apis;
|
||||
use std::fmt;
|
||||
|
||||
#[cfg(feature = "rpc")]
|
||||
pub use ethcore_rpc::Server as RpcServer;
|
||||
@@ -44,6 +45,17 @@ pub struct IpcConfiguration {
|
||||
pub apis: String,
|
||||
}
|
||||
|
||||
impl fmt::Display for IpcConfiguration {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
if self.enabled {
|
||||
write!(f, "endpoint address [{}], api list [{}]", self.socket_addr, self.apis)
|
||||
}
|
||||
else {
|
||||
write!(f, "disabled")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Dependencies {
|
||||
pub panic_handler: Arc<PanicHandler>,
|
||||
pub apis: Arc<rpc_apis::Dependencies>,
|
||||
@@ -66,12 +78,6 @@ pub fn new_http(conf: HttpConfiguration, deps: &Dependencies) -> Option<RpcServe
|
||||
Some(setup_http_rpc_server(deps, &addr, conf.cors, apis))
|
||||
}
|
||||
|
||||
pub fn new_ipc(conf: IpcConfiguration, deps: &Dependencies) -> Option<jsonipc::Server> {
|
||||
if !conf.enabled { return None; }
|
||||
let apis = conf.apis.split(',').collect();
|
||||
Some(setup_ipc_rpc_server(deps, &conf.socket_addr, apis))
|
||||
}
|
||||
|
||||
fn setup_rpc_server(apis: Vec<&str>, deps: &Dependencies) -> Server {
|
||||
let apis = rpc_apis::from_str(apis);
|
||||
let server = Server::new();
|
||||
@@ -109,10 +115,18 @@ pub fn setup_http_rpc_server(
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "rpc"))]
|
||||
pub fn setup_ipc_rpc_server(_dependencies: &Dependencies, _addr: &str, _apis: Vec<&str>) -> ! {
|
||||
die!("Your Parity version has been compiled without JSON-RPC support.")
|
||||
}
|
||||
|
||||
pub fn new_ipc(conf: IpcConfiguration, deps: &Dependencies) -> Option<jsonipc::Server> {
|
||||
if !conf.enabled { return None; }
|
||||
let apis = conf.apis.split(',').collect();
|
||||
Some(setup_ipc_rpc_server(deps, &conf.socket_addr, apis))
|
||||
}
|
||||
|
||||
#[cfg(feature = "rpc")]
|
||||
pub fn setup_ipc_rpc_server(dependencies: &Dependencies, addr: &str, apis: Vec<&str>) -> jsonipc::Server {
|
||||
let server = setup_rpc_server(apis, dependencies);
|
||||
|
||||
Reference in New Issue
Block a user