INNER CODE UNIT · Rust
create_daemon
upvpn/upvpn-app · upvpn-daemon/src/lib.rs:59
pub async fn create_daemon(shutdown_manager: &ShutdownManager) -> Result<Daemon, String> {
if already_running().await {
return Err("Upvpn Daemon is already running".to_owned());
}
#[cfg(any(target_os = "macos", target_os = "linux"))]
remove_old_socket_file().await;
// root user is required otherwise vpn setup will fail
user_check();
let db = Db::new().await?;
// Run DB migrations
tracing::info!("Running DB migration");
db.migrate().await?;
// Initialize device
let _ = initialize_device(db.connection()).await?;