Skip to content

Commit 2617ee7

Browse files
committed
Port management logic added
1 parent 1013101 commit 2617ee7

7 files changed

Lines changed: 2138 additions & 478 deletions

File tree

server/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ futures = "0.3.31"
3131
sled = "0.34.7"
3232
ctrlc = "3.4.7"
3333
regex = "1.11.1"
34+
console = "0.16.0"
3435
bytes = "1.10.0"
3536
hashbrown = "0.15.2"
3637
pest = "2.7.15"
@@ -50,6 +51,7 @@ memmap2 = "0.9.5"
5051
shared_memory = "0.12.4"
5152
log = "0.4.27"
5253
sysinfo = { version = "0.31.4", features = ["default", "serde"] }
54+
#[cfg(target_family = "unix")]
5355
nix = "0.29.0"
5456
libc = "0.2.169"
5557
prctl = "1.0.0"

server/src/cli/commands.rs

Lines changed: 48 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,21 @@ pub enum DaemonCliCommand {
4545
#[clap(long, short = 'p')]
4646
port: Option<u16>,
4747
},
48+
// These variants for Restart/Reload directly under DaemonCliCommand
49+
// are only for `graphdb-cli daemon restart` and `graphdb-cli daemon reload`.
50+
// The main `graphdb-cli restart` command uses RestartArgs/RestartAction.
51+
Restart {
52+
#[clap(long, short = 'p')]
53+
port: Option<u16>,
54+
#[clap(long, short = 'c', alias = "join-cluster")]
55+
cluster: Option<String>,
56+
},
57+
Reload {
58+
#[clap(long, short = 'p')]
59+
port: Option<u16>,
60+
#[clap(long, short = 'c', alias = "join-cluster")]
61+
cluster: Option<String>,
62+
},
4863
List,
4964
ClearAll,
5065
}
@@ -203,67 +218,68 @@ pub enum ReloadAction {
203218
#[clap(long, short = 'c', alias = "join-cluster")]
204219
cluster: Option<String>,
205220
#[clap(long)]
206-
rest: Option<bool>,
221+
rest: Option<bool>, // Should these apply to daemon? Usually not
207222
#[clap(long)]
208-
storage: Option<bool>,
223+
storage: Option<bool>, // Should these apply to daemon? Usually not
209224
},
210225
Rest {
211226
#[clap(long, short = 'p')]
212227
port: Option<u16>,
213228
#[clap(long, short = 'c', alias = "join-cluster")]
214-
cluster: Option<String>,
229+
cluster: Option<String>, // Cluster generally applies to storage/daemon, less to rest directly
215230
#[clap(long)]
216-
daemon: Option<bool>,
231+
daemon: Option<bool>, // Should these apply to rest? Usually not
217232
#[clap(long)]
218-
storage: Option<bool>,
233+
storage: Option<bool>, // Should these apply to rest? Usually not
219234
},
220235
Storage {
221236
#[clap(long, short = 'p')]
222237
port: Option<u16>,
223238
#[clap(long, value_hint = clap::ValueHint::FilePath)]
224239
config_file: Option<PathBuf>,
225240
#[clap(long)]
226-
daemon: Option<bool>,
241+
daemon: Option<bool>, // Should these apply to storage? Usually not
227242
#[clap(long)]
228-
rest: Option<bool>,
243+
rest: Option<bool>, // Should these apply to storage? Usually not
229244
},
230245
Cluster,
231246
}
232247

233248
#[derive(Debug, Args, PartialEq)]
234249
pub struct RestartArgs {
235250
#[clap(subcommand)]
236-
pub action: Option<RestartAction>,
251+
pub action: Option<RestartAction>, // Make action optional to allow top-level flags
252+
// Top-level flags that apply if no subcommand is given (implies RestartAction::All)
237253
#[clap(long, short = 'p')]
238254
pub port: Option<u16>,
239255
#[clap(long, short = 'c', alias = "join-cluster")]
240256
pub cluster: Option<String>,
241257
#[clap(long)]
242-
pub config_file: Option<PathBuf>,
258+
pub config_file: Option<PathBuf>, // General config for all or specific?
243259
#[clap(long)]
244-
pub listen_port: Option<u16>,
260+
pub listen_port: Option<u16>, // For daemon/rest
245261
#[clap(long)]
246-
pub storage_port: Option<u16>,
262+
pub storage_port: Option<u16>, // For storage
247263
#[clap(long, value_hint = clap::ValueHint::FilePath)]
248-
pub storage_config_file: Option<PathBuf>,
264+
pub storage_config_file: Option<PathBuf>, // Specific for storage
249265
#[clap(long, value_hint = clap::ValueHint::DirPath)]
250-
pub data_directory: Option<String>,
266+
pub data_directory: Option<String>, // Specific for storage
251267
#[clap(long, value_hint = clap::ValueHint::DirPath)]
252-
pub log_directory: Option<String>,
268+
pub log_directory: Option<String>, // Specific for storage/daemon/rest
253269
#[clap(long)]
254-
pub max_disk_space_gb: Option<u64>,
270+
pub max_disk_space_gb: Option<u64>, // Specific for storage
255271
#[clap(long)]
256-
pub min_disk_space_gb: Option<u64>,
272+
pub min_disk_space_gb: Option<u64>, // Specific for storage
257273
#[clap(long)]
258-
pub use_raft_for_scale: Option<bool>,
274+
pub use_raft_for_scale: Option<bool>, // Specific for storage
259275
#[clap(long)]
260-
pub storage_engine_type: Option<String>,
276+
pub storage_engine_type: Option<String>, // Specific for storage
261277
#[clap(long)]
262-
pub daemon: Option<bool>,
278+
pub daemon: Option<bool>, // Used with `restart all` or top-level to explicitly target daemon
263279
#[clap(long)]
264-
pub rest: Option<bool>,
280+
pub rest: Option<bool>, // Used with `restart all` or top-level to explicitly target rest
265281
#[clap(long)]
266-
pub storage: Option<bool>,
282+
pub storage: Option<bool>, // Used with `restart all` or top-level to explicitly target storage
267283
}
268284

269285
#[derive(Debug, Subcommand, PartialEq)]
@@ -305,8 +321,12 @@ pub enum RestartAction {
305321
port: Option<u16>,
306322
#[clap(long, short = 'c', alias = "join-cluster")]
307323
cluster: Option<String>,
324+
// These fields (rest, storage) might be redundant/confusing under Daemon
325+
// as they imply restarting other services *from* the daemon command.
326+
// If the intent is `restart daemon --rest --storage`, it's better handled by `restart all --daemon --rest --storage`.
327+
// I'll leave them for now as they were in your previous version, but note the ambiguity.
308328
#[clap(long)]
309-
daemon: Option<bool>,
329+
daemon: Option<bool>, // Redundant, implied by Daemon subcommand
310330
#[clap(long)]
311331
rest: Option<bool>,
312332
#[clap(long)]
@@ -316,11 +336,11 @@ pub enum RestartAction {
316336
#[clap(long, short = 'p')]
317337
port: Option<u16>,
318338
#[clap(long, short = 'c', alias = "join-cluster")]
319-
cluster: Option<String>,
339+
cluster: Option<String>, // Cluster usually not directly relevant for REST but kept for consistency
320340
#[clap(long)]
321-
daemon: Option<bool>,
341+
daemon: Option<bool>, // Redundant here
322342
#[clap(long)]
323-
storage: Option<bool>,
343+
storage: Option<bool>, // Redundant here
324344
},
325345
Storage {
326346
#[clap(long, short = 'p')]
@@ -342,11 +362,11 @@ pub enum RestartAction {
342362
#[clap(long)]
343363
storage_engine_type: Option<String>,
344364
#[clap(long)]
345-
daemon: Option<bool>,
365+
daemon: Option<bool>, // Redundant here
346366
#[clap(long)]
347-
rest: Option<bool>,
367+
rest: Option<bool>, // Redundant here
348368
},
349-
Cluster,
369+
Cluster, // A restart for the entire cluster (could imply specific actions on all nodes)
350370
}
351371

352372
#[derive(Debug, Args, PartialEq)]

0 commit comments

Comments
 (0)