Skip to content

Facility to bypass cli start to enable concurrency with other actors #1243

Answered by kaplanelad
casibbald asked this question in Q&A
Discussion options

You must be logged in to vote

Steps to Run Loco Without the CLI

  1. Remove the CLI Feature
    Open Cargo.toml and remove the cli feature from the loco-rs dependency.
    Replace:
    loco-rs = { workspace = true, features = ["cli"] }
    
    With:
    loco-rs = { workspace = true }
    
  2. Add a Custom Initializer
    Navigate to src/bin/main.rs and replace its contents with the following code:
use yair::{
    app::App,
    controllers::{kubecontroller::run, telemetry},
    core::kubecontroller::State,
};

#[tokio::main]
async fn main() -> loco_rs::Result<()> {
    let loco_rs_handle = tokio::spawn(async {
        if let Err(e) = run_loco_rs().await {
            eprintln!("Error in loco_rs: {:?}", e);
        }
    });

    // Await all tasks to comp…

Replies: 4 comments 14 replies

Comment options

You must be logged in to vote
6 replies
@kaplanelad
Comment options

@casibbald
Comment options

@kaplanelad
Comment options

@casibbald
Comment options

@casibbald
Comment options

Comment options

You must be logged in to vote
2 replies
@kaplanelad
Comment options

@casibbald
Comment options

Comment options

You must be logged in to vote
6 replies
@kaplanelad
Comment options

@casibbald
Comment options

@kaplanelad
Comment options

@casibbald
Comment options

@kaplanelad
Comment options

Answer selected by kaplanelad
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants