A simple python package for quick and easy microservices logging and configuration.
This package was created for fast and easy import in your application functional which important as part of any service but not so fun for developing each time. The most important thing for working with this library is a configuration file. I especially use .ini format because it is human-readable, simple to parse in python and disallow using large multi-level configuration.
1. Simple and good: `pip3 install service_utils`
2. Simple and not so good: just copy service_utils.py in your repository
3. Not so simple, but it allows you to have the last stable version of the library (if you really need): use .gitmodules file in your repository like this:
.gitmodules:
[submodule "service_utils"]
path = modules/service_utils
url = https://github.com/Sid1057/service_utils.git
branch = release
Sorry, I'll do it later
service_utils = Service_utils(
keys_required={
'-c': Service_utils.Actions.read_configuration,
'-p': Service_utils.Actions.write_pid_in_file
},
keys_optional={
},
config_sections={
},
description='interactive example of service utils')
# done
Using your program as service mean that you will run it in some operation system with some (maybe empty) arguments like:
python3 my_app.py -config config.ini --use-something --print-anything
Using this package mean that you agree with my thinks about configuration in applications and about part of a code which do this stuff:
- Configuration should be simple as possible.
- Configuration should be single in service.
- Configuration package should do maximum routine of posiible, but no more.
- Configuration package should have some default sections in the configuration file.
- Configuration package should allow a user (programmer) to do anything with configuration.
- Your application should have only one logger
Use
def kill_handler(frame, signal):
print('kill without -9 doesn\'t works here')
service_utils = Service_utils(
keys_required={
'-c': Service_utils.Actions.read_configuration,
'-p': Service_utils.Actions.write_pid_in_file
},
keys_optional={
},
config_sections={
},
signal_handlers={
signal.SIGINT: 22,
signal.SIGTERM: kill_handler
},
description='interactive example of service utils')
README is a little bit crap, but I work on it.
Sections TODO
- environment/containers
- CI/UI
- logging
- monitoring
- registration and location
- communications
- data base
- secourity
- scaling