@@ -7,21 +7,20 @@ use std::{
77 str:: FromStr ,
88} ;
99
10- use clap:: { ArgGroup , Parser , Subcommand } ;
10+ use clap:: { ArgGroup , Parser } ;
1111use jemallocator:: Jemalloc ;
1212use lading:: {
1313 blackhole,
1414 captures:: CaptureManager ,
1515 config:: { Config , Telemetry } ,
16- generator:: { self , process_tree } ,
16+ generator,
1717 inspector, observer,
1818 target:: { self , Behavior , Output } ,
1919 target_metrics,
2020} ;
2121use metrics:: gauge;
2222use metrics_exporter_prometheus:: PrometheusBuilder ;
2323use once_cell:: sync:: Lazy ;
24- use rand:: { SeedableRng , rngs:: StdRng } ;
2524use regex:: Regex ;
2625use rustc_hash:: FxHashMap ;
2726use tokio:: {
@@ -60,8 +59,6 @@ enum Error {
6059 CapturePath ,
6160 #[ error( "Invalid path for prometheus socket" ) ]
6261 PrometheusPath ,
63- #[ error( "Process tree failed to generate tree" ) ]
64- ProcessTree ( #[ from] process_tree:: Error ) ,
6562 #[ error( transparent) ]
6663 Registration ( #[ from] lading_signal:: RegisterError ) ,
6764}
@@ -212,31 +209,8 @@ struct Opts {
212209 /// whether to ignore inspector configuration, if present, and not run the inspector
213210 #[ clap( long) ]
214211 disable_inspector : bool ,
215- /// Extra sub commands
216- #[ clap( subcommand) ]
217- extracmds : Option < ExtraCommands > ,
218212}
219213
220- #[ derive( Subcommand , Debug ) ]
221- #[ clap( hide = true ) ]
222- enum ExtraCommands {
223- ProcessTreeGen ( ProcessTreeGen ) ,
224- }
225-
226- #[ derive( Parser , Debug ) ]
227- #[ clap( group(
228- ArgGroup :: new( "config" )
229- . required( true )
230- . args( & [ "config-path" , "config-content" ] ) ,
231- ) ) ]
232- struct ProcessTreeGen {
233- /// path on disk to the configuration file
234- #[ clap( long) ]
235- config_path : Option < PathBuf > ,
236- /// string repesanting the configuration
237- #[ clap( long) ]
238- config_content : Option < String > ,
239- }
240214
241215fn get_config ( ops : & Opts , config : Option < String > ) -> Result < Config , Error > {
242216 let contents = if let Some ( config) = config {
@@ -591,48 +565,6 @@ async fn inner_main(
591565 res
592566}
593567
594- fn run_process_tree ( opts : ProcessTreeGen ) -> Result < ( ) , Error > {
595- let mut contents = String :: new ( ) ;
596-
597- if let Some ( path) = opts. config_path {
598- debug ! (
599- "Attempting to open configuration file at: {}" ,
600- path. display( )
601- ) ;
602- let mut file: std:: fs:: File = std:: fs:: OpenOptions :: new ( )
603- . read ( true )
604- . open ( & path)
605- . unwrap_or_else ( |_| panic ! ( "Could not open configuration file at: {}" , path. display( ) ) ) ;
606-
607- file. read_to_string ( & mut contents) ?;
608- } else if let Some ( str) = & opts. config_content {
609- contents = str. to_string ( )
610- } else {
611- unreachable ! ( "clap ensures that exactly one target option is selected" ) ;
612- } ;
613-
614- match process_tree:: get_config ( & contents) {
615- Ok ( config) => {
616- info ! ( "Generating a process tree." ) ;
617-
618- let mut rng = StdRng :: from_seed ( config. seed ) ;
619- let nodes = process_tree:: generate_tree ( & mut rng, & config) ?;
620-
621- process_tree:: spawn_tree ( & nodes, config. process_sleep_ns . get ( ) ) ?;
622-
623- info ! ( "Bye. :)" ) ;
624- }
625- Err ( e) => panic ! ( "invalide configuration: {e}" ) ,
626- }
627- Ok ( ( ) )
628- }
629-
630- fn run_extra_cmds ( cmds : ExtraCommands ) -> Result < ( ) , Error > {
631- match cmds {
632- // This command will call fork and the process must be kept fork-safe up to this point.
633- ExtraCommands :: ProcessTreeGen ( opts) => run_process_tree ( opts) ,
634- }
635- }
636568
637569fn main ( ) -> Result < ( ) , Error > {
638570 tracing_subscriber:: fmt ( )
@@ -645,11 +577,6 @@ fn main() -> Result<(), Error> {
645577 info ! ( "Starting lading {version} run." ) ;
646578 let opts: Opts = Opts :: parse ( ) ;
647579
648- // handle extra commands
649- if let Some ( cmds) = opts. extracmds {
650- run_extra_cmds ( cmds) ?;
651- return Ok ( ( ) ) ;
652- }
653580
654581 let config = get_config ( & opts, None ) ;
655582
0 commit comments