Process Manager is a terminal-based tool written in Go for managing processes. The application allows you to launch, monitor, and view logs of processes in real time through a convenient TUI (Text User Interface) built with Bubble Tea.
- Automatically launches processes from a configuration file on startup.
- Add new processes during runtime.
- Automatic Restart: If a process unexpectedly terminates or completes normally, it will be restarted automatically based on its configuration.
- View logs of running processes with scrolling and force-kill functionality.
- Limits log size per process (up to 1000 lines) to prevent excessive memory usage.
- Automatically backs up and resets the configuration file if it becomes unreadable.
- Go 1.16 or newer.
- Supported platforms: Windows, Linux, macOS.
- Go module dependencies:
-
Clone the repository:
git clone https://github.com/yourusername/process-manager.git cd process-manager -
Install dependencies:
Make sure you have Go installed. Then run:
go mod download
-
Build the project:
go build -o process-manager
This will compile the executable
process-managerin the current directory.
-
Run the application:
./process-manager
On the first run, a configuration file named
process_manager_config.jsonwill be created in the same directory as the executable. -
Configuration File:
The
process_manager_config.jsonfile holds a list of processes to be launched automatically. Its format:{ "processes": [ { "cmd_line": "command_1", "auto_restart": true }, { "cmd_line": "command_2", "auto_restart": false } ] }- cmd_line: The command line to execute the process.
- auto_restart: If set to
true, the process will automatically restart upon termination.
Note:
If the configuration file cannot be read (due to corruption or invalid format), the application will rename the existingprocess_manager_config.jsontoprocess_manager_config.json.oldand create a new default configuration file. -
Application Interface:
- Process List: Upon launch, the interface displays a list of running processes. The last item in the list allows you to create a new process.
- Adding a Process: Select the option to create a new process, enter the command, and press
Enter. You can toggle the auto-restart option by pressingTab. - Viewing Logs: Select an existing process from the list and press
Enterto view its logs. In log view mode:- Use the
↑/↓arrow keys ork/jto scroll. - Press
ctrl+kto forcefully kill the process. - Press
Escto return to the process list.
- Use the
- Exit: Press
qorctrl+cto quit the application. All unfinished processes will be terminated gracefully.
- Each process's logs are stored in memory up to 1000 lines. Older lines are removed as new lines are added to maintain this limit.
- On Windows, UTF-8 encoding is set for proper character display (the code runs
chcp 65001). - Ensure your terminal supports Alternate Screen Mode for optimal display.
This project is licensed under the MIT License.