core_daemon/README.md
2024-08-06 22:40:10 +03:00

1.6 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

  1. Start the core daemon:

python3 core_daemon.py

  1. 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' directory
  • load <module_name>: Load a module
  • unload <module_name>: Unload a module
  • list: List all currently loaded modules
  • upgrade: 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:

  1. Create a new Python file in the 'modules' directory
  2. Define your module as a class
  3. 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

  • Create module to add auth for the cli connections...
  • Create module for module to module communication...