MCPcopy Create free account
hub / github.com/ermak-dev/cloudpub / init

Function init

client/src/base.rs:120–148  ·  view source on GitHub ↗
(args: &Cli)

Source from the content-addressed store, hash-verified

118}
119
120pub fn init(args: &Cli) -> Result<(WorkerGuard, Arc<RwLock<ClientConfig>>)> {
121 // Raise `nofile` limit on linux and mac
122 if let Err(err) = fdlimit::raise_fd_limit() {
123 warn!("Failed to raise file descriptor limit: {}", err);
124 }
125
126 // Create log directory
127 let log_dir = cache_dir().context("Can't get cache dir")?.join("cloudpub");
128 std::fs::create_dir_all(&log_dir).context("Can't create log dir")?;
129
130 let log_file = log_dir.join("client.log");
131
132 let guard = init_log(
133 &args.log_level,
134 &log_file,
135 args.verbose,
136 10 * 1024 * 1024,
137 2,
138 )
139 .context("Failed to initialize logging")?;
140
141 let config = if let Some(path) = args.conf.as_ref() {
142 ClientConfig::from_file(&path.into(), args.readonly)?
143 } else {
144 ClientConfig::load(CONFIG_FILE, true, args.readonly)?
145 };
146 let config = Arc::new(RwLock::new(config));
147 Ok((guard, config))
148}
149
150#[tokio::main]
151pub async fn cli_main(cli: Cli, config: Arc<RwLock<ClientConfig>>) -> Result<()> {

Callers 3

mainFunction · 0.85
run_appFunction · 0.85
init_logFunction · 0.85

Calls 1

init_logFunction · 0.85

Tested by

no test coverage detected