Skip to main content

Process

Class: Process

A class that provides process management capabilities.

Static Methods

exec

static exec(command: string, args: string[]): Promise<Process>

Executes a command and returns a Process instance.

  • Parameters:
    • command: The command to execute
    • args: Array of command arguments
  • Returns: Promise<Process>

kill

static kill(id: string): Promise<boolean>

Kills a process by its ID.

  • Parameters:
    • id: Process ID
  • Returns: Promise<boolean>

list

static list(): Promise<ProcessInfo[]>

Lists all running processes.

  • Returns: Promise<ProcessInfo[]>

info

static info(id: string): Promise<ProcessInfo>

Gets information about a specific process.

  • Parameters:
    • id: Process ID
  • Returns: Promise<ProcessInfo>

Instance Methods

id

get id(): string

Gets the process ID.

  • Returns: string

kill

kill(): Promise<boolean>

Kills the current process.

  • Returns: Promise<boolean>

info

info(): Promise<ProcessInfo>

Gets information about the current process.

  • Returns: Promise<ProcessInfo>

logEvents

logEvents(): LogEventWatcher

Gets a log event watcher for the process.

  • Returns: LogEventWatcher

Class: LogEventWatcher

A class that extends EventWatcher for handling process log events.

Methods

close

close(): void

Closes the log event watcher.

Enums

ProcessStatus

enum ProcessStatus {
Running = "running",
Killed = "killed",
Exited = "exited"
}

ProcessEvent

enum ProcessEvent {
Running = "processRunning",
Killed = "processKilled",
Exited = "processExited"
}

LogEvent

enum LogEvent {
Data = "data",
End = "end",
Out = "out",
Error = "error"
}

Interfaces

ProcessInfo

interface ProcessInfo {
id: string;
status: ProcessStatus;
memory: number;
}