mirror of
https://github.com/Cyrix126/gupaxx.git
synced 2024-12-22 14:49:21 +00:00
feat: prevent running a service when another instance is running locally
Some checks failed
CI / ci (macos-12) (push) Has been cancelled
CI / ci (ubuntu-latest) (push) Has been cancelled
Rust / fmt (push) Has been cancelled
Rust / test (macos-latest) (push) Has been cancelled
Rust / test (ubuntu-latest) (push) Has been cancelled
Rust / typo (push) Has been cancelled
Rust / clippy (macos-latest) (push) Has been cancelled
Rust / clippy (ubuntu-latest) (push) Has been cancelled
Rust / check (macos-latest) (push) Has been cancelled
Rust / check (ubuntu-latest) (push) Has been cancelled
Rust / doc (macos-latest) (push) Has been cancelled
Rust / doc (ubuntu-latest) (push) Has been cancelled
Typo / typo (push) Has been cancelled
Some checks failed
CI / ci (macos-12) (push) Has been cancelled
CI / ci (ubuntu-latest) (push) Has been cancelled
Rust / fmt (push) Has been cancelled
Rust / test (macos-latest) (push) Has been cancelled
Rust / test (ubuntu-latest) (push) Has been cancelled
Rust / typo (push) Has been cancelled
Rust / clippy (macos-latest) (push) Has been cancelled
Rust / clippy (ubuntu-latest) (push) Has been cancelled
Rust / check (macos-latest) (push) Has been cancelled
Rust / check (ubuntu-latest) (push) Has been cancelled
Rust / doc (macos-latest) (push) Has been cancelled
Rust / doc (ubuntu-latest) (push) Has been cancelled
Typo / typo (push) Has been cancelled
This commit is contained in:
parent
e0ece356a0
commit
ad2100d461
3 changed files with 12 additions and 6 deletions
|
@ -5,6 +5,7 @@ use crate::disk::node::Node;
|
||||||
use crate::disk::pool::Pool;
|
use crate::disk::pool::Pool;
|
||||||
use crate::disk::state::{Gupax, State};
|
use crate::disk::state::{Gupax, State};
|
||||||
use crate::disk::status::Submenu;
|
use crate::disk::status::Submenu;
|
||||||
|
use crate::errors::process_running;
|
||||||
use crate::helper::{Helper, ProcessSignal, ProcessState};
|
use crate::helper::{Helper, ProcessSignal, ProcessState};
|
||||||
use crate::utils::constants::*;
|
use crate::utils::constants::*;
|
||||||
use crate::utils::errors::{ErrorButtons, ErrorFerris};
|
use crate::utils::errors::{ErrorButtons, ErrorFerris};
|
||||||
|
@ -378,6 +379,9 @@ impl crate::app::App {
|
||||||
) {
|
) {
|
||||||
ui_enabled = false;
|
ui_enabled = false;
|
||||||
text = format!("Error: {}", P2POOL_PATH_NOT_VALID);
|
text = format!("Error: {}", P2POOL_PATH_NOT_VALID);
|
||||||
|
} else if process_running(crate::helper::ProcessName::P2pool) {
|
||||||
|
ui_enabled = false;
|
||||||
|
text = format!("Error: {}", PROCESS_OUTSIDE);
|
||||||
}
|
}
|
||||||
ui.add_enabled_ui(ui_enabled, |ui| {
|
ui.add_enabled_ui(ui_enabled, |ui| {
|
||||||
let color = if ui_enabled { GREEN } else { RED };
|
let color = if ui_enabled { GREEN } else { RED };
|
||||||
|
@ -530,6 +534,9 @@ impl crate::app::App {
|
||||||
{
|
{
|
||||||
ui_enabled = false;
|
ui_enabled = false;
|
||||||
text = format!("Error: {}", XMRIG_PATH_NOT_VALID);
|
text = format!("Error: {}", XMRIG_PATH_NOT_VALID);
|
||||||
|
} else if process_running(crate::helper::ProcessName::Xmrig) {
|
||||||
|
ui_enabled = false;
|
||||||
|
text = format!("Error: {}", PROCESS_OUTSIDE);
|
||||||
}
|
}
|
||||||
ui.add_enabled_ui(ui_enabled, |ui| {
|
ui.add_enabled_ui(ui_enabled, |ui| {
|
||||||
let color = if ui_enabled { GREEN } else { RED };
|
let color = if ui_enabled { GREEN } else { RED };
|
||||||
|
@ -729,6 +736,9 @@ impl crate::app::App {
|
||||||
) {
|
) {
|
||||||
ui_enabled = false;
|
ui_enabled = false;
|
||||||
text = format!("Error: {}", XMRIG_PROXY_PATH_NOT_VALID);
|
text = format!("Error: {}", XMRIG_PROXY_PATH_NOT_VALID);
|
||||||
|
} else if process_running(crate::helper::ProcessName::XmrigProxy) {
|
||||||
|
ui_enabled = false;
|
||||||
|
text = format!("Error: {}", PROCESS_OUTSIDE);
|
||||||
}
|
}
|
||||||
ui.add_enabled_ui(ui_enabled, |ui| {
|
ui.add_enabled_ui(ui_enabled, |ui| {
|
||||||
let color = if ui_enabled { GREEN } else { RED };
|
let color = if ui_enabled { GREEN } else { RED };
|
||||||
|
|
|
@ -407,7 +407,6 @@ pub const LIST_ADD: &str = "Add the current values to the list";
|
||||||
pub const LIST_SAVE: &str = "Save the current values to the already existing entry";
|
pub const LIST_SAVE: &str = "Save the current values to the already existing entry";
|
||||||
pub const LIST_DELETE: &str = "Delete the currently selected entry";
|
pub const LIST_DELETE: &str = "Delete the currently selected entry";
|
||||||
pub const LIST_CLEAR: &str = "Clear all current values";
|
pub const LIST_CLEAR: &str = "Clear all current values";
|
||||||
|
|
||||||
// XMRig
|
// XMRig
|
||||||
pub const XMRIG_SIMPLE: &str = r#"Use simple XMRig settings:
|
pub const XMRIG_SIMPLE: &str = r#"Use simple XMRig settings:
|
||||||
- Mine to local P2Pool (localhost:3333)
|
- Mine to local P2Pool (localhost:3333)
|
||||||
|
@ -502,7 +501,8 @@ pub const BLOCK_PPLNS_WINDOW_MAIN: u64 = 363;
|
||||||
pub const SECOND_PER_BLOCK_P2POOL: u64 = 10;
|
pub const SECOND_PER_BLOCK_P2POOL: u64 = 10;
|
||||||
// pub const TIME_PPLNS_WINDOW_MINI: Duration = Duration::from_secs(BLOCK_PPLNS_WINDOW_MINI * SECOND_PER_BLOCK_P2POOL);
|
// pub const TIME_PPLNS_WINDOW_MINI: Duration = Duration::from_secs(BLOCK_PPLNS_WINDOW_MINI * SECOND_PER_BLOCK_P2POOL);
|
||||||
// pub const TIME_PPLNS_WINDOW_MAIN: Duration = Duration::from_secs(BLOCK_PPLNS_WINDOW_MAIN * SECOND_PER_BLOCK_P2POOL);
|
// pub const TIME_PPLNS_WINDOW_MAIN: Duration = Duration::from_secs(BLOCK_PPLNS_WINDOW_MAIN * SECOND_PER_BLOCK_P2POOL);
|
||||||
|
pub const PROCESS_OUTSIDE: &str =
|
||||||
|
"This process is running outside of Gupaxx.\nYou need to stop it before starting it in Gupaxx.";
|
||||||
//---------------------------------------------------------------------------------------------------- Visuals
|
//---------------------------------------------------------------------------------------------------- Visuals
|
||||||
use egui::epaint::{Rounding, Shadow, Stroke};
|
use egui::epaint::{Rounding, Shadow, Stroke};
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
|
|
||||||
#[cfg(target_os = "windows")]
|
|
||||||
use sysinfo::System;
|
use sysinfo::System;
|
||||||
|
|
||||||
#[cfg(target_os = "windows")]
|
|
||||||
use crate::helper::ProcessName;
|
use crate::helper::ProcessName;
|
||||||
|
|
||||||
use super::sudo::SudoState;
|
use super::sudo::SudoState;
|
||||||
|
@ -98,13 +96,11 @@ impl ErrorState {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "windows")]
|
|
||||||
pub fn process_running(process_name: ProcessName) -> bool {
|
pub fn process_running(process_name: ProcessName) -> bool {
|
||||||
let name = match process_name {
|
let name = match process_name {
|
||||||
ProcessName::P2pool => "p2pool",
|
ProcessName::P2pool => "p2pool",
|
||||||
ProcessName::Xmrig => "xmrig",
|
ProcessName::Xmrig => "xmrig",
|
||||||
ProcessName::XmrigProxy => "xmrig-proxy",
|
ProcessName::XmrigProxy => "xmrig-proxy",
|
||||||
ProcessName::Node => "monerod",
|
|
||||||
ProcessName::Xvb => panic!("XvB does not exist as a process outside of Gupaxx"),
|
ProcessName::Xvb => panic!("XvB does not exist as a process outside of Gupaxx"),
|
||||||
};
|
};
|
||||||
let s = System::new_all();
|
let s = System::new_all();
|
||||||
|
|
Loading…
Reference in a new issue