pub struct ProcessManager { /* private fields */ }Expand description
Gerenciador de Processos.
Controla o ciclo de vida de todos os processos das aplicações.
Thread-safe através de Arc
§Exemplo
let manager = ProcessManager::new();
manager.launch_app(&app_config);
if manager.is_running(&app_config.id) {
manager.stop_app(&app_config.id);
}Implementations§
Source§impl ProcessManager
impl ProcessManager
Sourcepub fn running_apps(&self) -> Arc<Mutex<HashMap<String, RunningProcess>>>
pub fn running_apps(&self) -> Arc<Mutex<HashMap<String, RunningProcess>>>
Retorna uma referência Arc para os processos em execução
Sourcepub fn loading_apps(&self) -> Arc<Mutex<HashSet<String>>>
pub fn loading_apps(&self) -> Arc<Mutex<HashSet<String>>>
Retorna uma referência Arc para as aplicações em loading
Sourcepub fn launch_app(&self, app: &AppConfig)
pub fn launch_app(&self, app: &AppConfig)
Inicia uma aplicação em um novo terminal Windows.
Este método:
- Para qualquer processo anterior da mesma aplicação
- Marca a aplicação como “loading”
- Cria um arquivo batch temporário com os comandos
- Executa o batch em um novo terminal
- Registra o processo em execução
§Argumentos
app- Configuração da aplicação a ser iniciada
Sourcepub fn stop_app(
&self,
app_id: &str,
app_name: Option<&str>,
commands: Option<&Vec<String>>,
)
pub fn stop_app( &self, app_id: &str, app_name: Option<&str>, commands: Option<&Vec<String>>, )
Para uma aplicação em execução.
Utiliza múltiplas estratégias para garantir que o processo seja terminado:
- Mata pelo título do comando
- Mata pelo título [IRIS]
- Mata pela árvore de processos (PID)
- Usa WMIC para matar pelo CommandLine
§Argumentos
app_id- ID da aplicação a ser paradaapp_name- Nome opcional da aplicação (para busca por título)commands- Comandos opcionais (para busca por título)
Sourcepub fn restart_app(&self, app: &AppConfig)
pub fn restart_app(&self, app: &AppConfig)
Reinicia uma aplicação.
Para o processo atual e inicia novamente após um pequeno delay.
Sourcepub fn is_running(&self, app_id: &str) -> bool
pub fn is_running(&self, app_id: &str) -> bool
Verifica se uma aplicação está em execução
Sourcepub fn is_loading(&self, app_id: &str) -> bool
pub fn is_loading(&self, app_id: &str) -> bool
Verifica se uma aplicação está em processo de inicialização
Sourcepub fn running_count(&self) -> usize
pub fn running_count(&self) -> usize
Retorna o número de aplicações em execução
Sourcepub fn has_loading(&self) -> bool
pub fn has_loading(&self) -> bool
Verifica se há alguma aplicação em loading
Sourcepub fn has_running(&self) -> bool
pub fn has_running(&self) -> bool
Verifica se há alguma aplicação em execução
Sourcepub fn cleanup_dead_processes(&self)
pub fn cleanup_dead_processes(&self)
Limpa processos que morreram do registro.
Verifica se os processos registrados ainda estão ativos e remove os que foram encerrados.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ProcessManager
impl RefUnwindSafe for ProcessManager
impl Send for ProcessManager
impl Sync for ProcessManager
impl Unpin for ProcessManager
impl UnsafeUnpin for ProcessManager
impl UnwindSafe for ProcessManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().