Skip to main content

Mountain/Binary/Service/
CocoonStart.rs

1//! # Cocoon Start Module
2//!
3//! Initializes and starts the Cocoon sidecar process.
4
5use crate::{
6	Environment::MountainEnvironment::MountainEnvironment,
7	ProcessManagement::CocoonManagement::InitializeCocoon,
8	dev_log,
9};
10
11/// Starts the Cocoon sidecar process for build tool support.
12///
13/// # Arguments
14///
15/// * `ApplicationHandle` - The Tauri application handle
16/// * `Environment` - The Mountain environment instance
17///
18/// # Returns
19///
20/// A `Result` indicating success or failure.
21///
22/// # Cocoon Sidecar Functionality
23///
24/// The Cocoon sidecar provides:
25/// - Build tool integration
26/// - Process management for external tools
27/// - Communication bridge with external build processes
28///
29/// # Errors
30///
31/// Returns an error if Cocoon initialization fails.
32pub async fn CocoonStart(
33	ApplicationHandle:&tauri::AppHandle,
34
35	Environment:&std::sync::Arc<MountainEnvironment>,
36) -> Result<(), String> {
37	match InitializeCocoon(ApplicationHandle, Environment).await {
38		Ok(()) => {
39			dev_log!("cocoon", "[Cocoon] [Start] Cocoon sidecar started successfully.");
40
41			Ok(())
42		},
43
44		Err(e) => {
45			dev_log!("cocoon", "warn: [Cocoon] [Start] Cocoon unavailable (degraded mode): {}", e);
46
47			Ok(()) // Graceful degradation - workbench works without Cocoon
48		},
49	}
50}