Skip to content

Do daemon uniqueness check before rotating logs #5847

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Line wrap the file at 100 chars. Th
### Fixed
- Continual excessive attempts to update the API IP were made after testing access methods.
- Fix pointless API access method rotations for concurrent requests.
- Fix daemon rotating logs on startup even if another daemon is already running.

### Security
#### Android
Expand Down
20 changes: 11 additions & 9 deletions mullvad-daemon/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,24 @@ const EARLY_BOOT_LOG_FILENAME: &str = "early-boot-fw.log";

fn main() {
let config = cli::get_config();

let runtime = new_runtime_builder().build().unwrap_or_else(|error| {
eprintln!("{}", error.display_chain());
std::process::exit(1);
});

if runtime.block_on(rpc_uniqueness_check::is_another_instance_running()) {
eprintln!("Another instance of the daemon is already running");
std::process::exit(1)
}

let log_dir = init_daemon_logging(config).unwrap_or_else(|error| {
eprintln!("{error}");
std::process::exit(1)
});

log::trace!("Using configuration: {:?}", config);

let runtime = new_runtime_builder().build().unwrap_or_else(|error| {
eprintln!("{}", error.display_chain());
std::process::exit(1);
});

let exit_code = match runtime.block_on(run_platform(config, log_dir)) {
Ok(_) => 0,
Err(error) => {
Expand Down Expand Up @@ -144,10 +150,6 @@ async fn run_platform(_config: &cli::Config, log_dir: Option<PathBuf>) -> Result
}

async fn run_standalone(log_dir: Option<PathBuf>) -> Result<(), String> {
if rpc_uniqueness_check::is_another_instance_running().await {
return Err("Another instance of the daemon is already running".to_owned());
}

#[cfg(any(target_os = "macos", target_os = "linux"))]
if let Err(err) = tokio::fs::remove_file(mullvad_paths::get_rpc_socket_path()).await {
if err.kind() != std::io::ErrorKind::NotFound {
Expand Down