1.7 KiB
1.7 KiB
core_daemon
My attempt of creating python daemon handler. This was written with Python 3.11
Features
- Core daemon that runs continuously and manages modules
- Interactive shell for user interaction
- Dynamic loading and unloading of modules
- Custom command execution from loaded modules
- Auto-completion for commands in the shell
- Ability to upgrade the core daemon
- Modules are loaded from an 'modules' directory
Structure
dynamic-module-manager/ ├── core_daemon.py ├── daemon_cli.py ├── modules/ │ ├── extra_commands.py │ └── http_service.py └── README.md
Getting Started
- Start the core daemon:
python3 core_daemon.py
- In a separate terminal, start the shell:
python3 shell.py
Usage
Once in the shell, you can use the following commands:
list_available
: List all available modules in the 'modules' directoryload <module_name>
: Load a moduleunload <module_name>
: Unload a modulelist
: List all currently loaded modulesupgrade
: Upgrade the core daemon (restarts the daemon in current implementation)- Any custom commands provided by loaded modules
Use tab completion to see available commands and modules.
Creating New Modules
To create a new module:
- Create a new Python file in the 'modules' directory
- Define your module as a class
- Implement at least one of these functions
initialize()
,shutdown()
,get_commands()
See modules/extra_commands.py
and modules/http_service.py
for an example of how to structure a module.
Todo
-
Maybe add ability to search for modules in directories set by a command
-
Create module to add auth for the cli connections...
-
Add error handling to core_daemon and daemon_cli...