Skip to content

Commit

Permalink
Merge #1469: liana: remove daemon feature
Browse files Browse the repository at this point in the history
c14c55b remove daemonize from config (edouardparis)
c8112ab move rpc code to its own module (edouardparis)
a636cda liana: remove the daemon feature (edouardparis)

Pull request description:

  We expect user to use systemd service to manage a daemon or
  to handle their process by themself.

  The json-rpc server is exposed only for unix systems through
  unix sockets, it is moved to its own module while the implementation
  for windows is marked as TODO.

ACKs for top commit:
  jp1ac4:
    ACK c14c55b.

Tree-SHA512: d4acafda399e9645cb5a80474a46290b6fac1e9695bb6ce04ce1eec7f68209ae67c70f858cd8f4d3ea5371818c2d5f68f9bcb3e4da349f5f86e53c0ec1123883
  • Loading branch information
edouardparis committed Nov 19, 2024
2 parents d83f34c + c14c55b commit 9c6eae9
Show file tree
Hide file tree
Showing 14 changed files with 273 additions and 402 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions contrib/lianad_config_example.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# Whether to run the process as a UNIX daemon (double fork magic)
daemon = false

# (Optional) Path to the folder where we should store the application data.
# Defaults to `.lianad` in your home folder.
data_dir = "/home/wizardsardine/.lianad"
Expand Down
7 changes: 0 additions & 7 deletions liana/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,12 @@ exclude = [".github/", ".cirrus.yml", "tests/", "test_data/", "contrib/", "pypr
[[bin]]
name = "lianad"
path = "src/bin/daemon.rs"
required-features = ["daemon"]

[[bin]]
name = "liana-cli"
path = "src/bin/cli.rs"
required-features = ["daemon"]

[features]
default = ["daemon"]
daemon = ["libc"]
nonblocking_shutdown = []

[dependencies]
Expand Down Expand Up @@ -59,9 +55,6 @@ rusqlite = { version = "0.30", features = ["bundled", "unlock_notify"] }
# To talk to bitcoind
jsonrpc = { version = "0.17", features = ["minreq_http"], default-features = false }

# Used for daemonization
libc = { version = "0.2", optional = true }

# Used for generating mnemonics
getrandom = "0.2"

Expand Down
7 changes: 1 addition & 6 deletions liana/src/bin/daemon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,7 @@ fn main() {
process::exit(1);
});

let handle = DaemonHandle::start_default(
config,
#[cfg(all(unix, feature = "daemon"))]
true,
)
.unwrap_or_else(|e| {
let handle = DaemonHandle::start_default(config, cfg!(unix)).unwrap_or_else(|e| {
log::error!("Error starting Liana daemon: {}", e);
process::exit(1);
});
Expand Down
19 changes: 0 additions & 19 deletions liana/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,6 @@ fn default_poll_interval() -> Duration {
Duration::from_secs(30)
}

#[cfg(unix)]
fn default_daemon() -> bool {
false
}

/// Bitcoin backend config.
#[derive(Debug, Clone, Deserialize, Serialize)]
pub enum BitcoinBackend {
Expand Down Expand Up @@ -153,10 +148,6 @@ pub struct BitcoinConfig {
pub struct Config {
/// An optional custom data directory
pub data_dir: Option<PathBuf>,
/// Whether to daemonize the process
#[cfg(unix)]
#[serde(default = "default_daemon")]
pub daemon: bool,
/// What messages to log
#[serde(
deserialize_with = "deserialize_fromstr",
Expand Down Expand Up @@ -303,7 +294,6 @@ mod tests {
// A valid config
let toml_str = r#"
data_dir = "/home/wizardsardine/custom/folder/"
daemon = false
log_level = "debug"
main_descriptor = "wsh(andor(pk([aabbccdd]tpubDEN9WSToTyy9ZQfaYqSKfmVqmq1VVLNtYfj3Vkqh67et57eJ5sTKZQBkHqSwPUsoSskJeaYnPttHe2VrkCsKA27kUaN9SDc5zhqeLzKa1rr/<0;1>/*),older(10000),pk([aabbccdd]tpubD8LYfn6njiA2inCoxwM7EuN3cuLVcaHAwLYeups13dpevd3nHLRdK9NdQksWXrhLQVxcUZRpnp5CkJ1FhE61WRAsHxDNAkvGkoQkAeWDYjV/<0;1>/*)))#dw4ulnrs"
Expand All @@ -318,11 +308,9 @@ mod tests {
toml::from_str::<Config>(&toml_str).expect("Deserializing toml_str");

// A valid, round-tripping, config
#[cfg(unix)] // On non-UNIX there is no 'daemon' member.
{
let toml_str = r#"
data_dir = '/home/wizardsardine/custom/folder/'
daemon = false
log_level = 'TRACE'
main_descriptor = 'wsh(andor(pk([aabbccdd]tpubDEN9WSToTyy9ZQfaYqSKfmVqmq1VVLNtYfj3Vkqh67et57eJ5sTKZQBkHqSwPUsoSskJeaYnPttHe2VrkCsKA27kUaN9SDc5zhqeLzKa1rr/<0;1>/*),older(10000),pk([aabbccdd]tpubD8LYfn6njiA2inCoxwM7EuN3cuLVcaHAwLYeups13dpevd3nHLRdK9NdQksWXrhLQVxcUZRpnp5CkJ1FhE61WRAsHxDNAkvGkoQkAeWDYjV/<0;1>/*)))#dw4ulnrs'
Expand All @@ -340,12 +328,9 @@ mod tests {
}

// A valid, round-tripping, config for a Taproot descriptor.

#[cfg(unix)] // On non-UNIX there is no 'daemon' member.
{
let toml_str = r#"
data_dir = '/home/wizardsardine/custom/folder/'
daemon = false
log_level = 'TRACE'
main_descriptor = 'tr([abcdef01]xpub6Eze7yAT3Y1wGrnzedCNVYDXUqa9NmHVWck5emBaTbXtURbe1NWZbK9bsz1TiVE7Cz341PMTfYgFw1KdLWdzcM1UMFTcdQfCYhhXZ2HJvTW/<0;1>/*,and_v(v:pk([abcdef01]xpub688Hn4wScQAAiYJLPg9yH27hUpfZAUnmJejRQBCiwfP5PEDzjWMNW1wChcninxr5gyavFqbbDjdV1aK5USJz8NDVjUy7FRQaaqqXHh5SbXe/<0;1>/*),older(52560)))#0mt7e93c'
Expand All @@ -363,11 +348,9 @@ mod tests {
}

// A valid, round-tripping, config with `auth` instead of `cookie_path`
#[cfg(unix)] // On non-UNIX there is no 'daemon' member.
{
let toml_str = r#"
data_dir = '/home/wizardsardine/custom/folder/'
daemon = false
log_level = 'TRACE'
main_descriptor = 'wsh(andor(pk([aabbccdd]tpubDEN9WSToTyy9ZQfaYqSKfmVqmq1VVLNtYfj3Vkqh67et57eJ5sTKZQBkHqSwPUsoSskJeaYnPttHe2VrkCsKA27kUaN9SDc5zhqeLzKa1rr/<0;1>/*),older(10000),pk([aabbccdd]tpubD8LYfn6njiA2inCoxwM7EuN3cuLVcaHAwLYeups13dpevd3nHLRdK9NdQksWXrhLQVxcUZRpnp5CkJ1FhE61WRAsHxDNAkvGkoQkAeWDYjV/<0;1>/*)))#dw4ulnrs'
Expand All @@ -386,7 +369,6 @@ mod tests {

// Invalid desc checksum
let toml_str = r#"
daemon = false
log_level = "trace"
data_dir = "/home/wizardsardine/custom/folder/"
Expand All @@ -405,7 +387,6 @@ mod tests {

// Not enough parameters: missing the Bitcoin network
let toml_str = r#"
daemon = false
log_level = "trace"
data_dir = "/home/wizardsardine/custom/folder/"
Expand Down
69 changes: 0 additions & 69 deletions liana/src/daemonize.rs

This file was deleted.

2 changes: 1 addition & 1 deletion liana/src/jsonrpc/api.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{
commands::{CoinStatus, LabelItem},
jsonrpc::{Error, Params, Request, Response},
jsonrpc::rpc::{Error, Params, Request, Response},
DaemonControl,
};

Expand Down
Loading

0 comments on commit 9c6eae9

Please sign in to comment.