Skip to content
This repository has been archived by the owner on Oct 17, 2022. It is now read-only.

Prevent exit to prevent kernel panic #30

Open
future-highway opened this issue Sep 30, 2022 · 3 comments
Open

Prevent exit to prevent kernel panic #30

future-highway opened this issue Sep 30, 2022 · 3 comments
Labels

Comments

@future-highway
Copy link
Collaborator

Via MalteJ, "auraed must not exit if something bad happens. When running as pid 1, we get a kernel panic, when pid 1 exits. We could trigger a reboot instead."

A panic in the daemon will only crash the thread, not the program, as everything is in a thread handled by tokio. As long as tokio's crash/exit is handled, then auraed can be prevented from exiting, hopefully.

A simple loop to restart the daemon may be an appropriate solution:

#[tokio::main]
async fn main() {
    loop {
        let exit_code = daemon().await;
        println!("daemon stopped with exit code: {}", exit_code);
        println!("restarting daemon...");
    }

    panic!("auraed should never exit!");
}

replacing

async fn main() -> Result<(), Box<dyn std::error::Error>> {

@MalteJ
Copy link
Contributor

MalteJ commented Sep 30, 2022

We should add a sleep at the end of the loop. Otherwise, if daemon() exits quickly we'd end up with 100% CPU usage and an infinite loop.

@Vincinator
Copy link
Collaborator

linking related Issue #22

@MalteJ MalteJ added the PID 1 label Oct 1, 2022
@future-highway
Copy link
Collaborator Author

catch_unwind may also be useful

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants