-
Notifications
You must be signed in to change notification settings - Fork 1
Fix doc generation, introduce basic README. #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
+99
−5
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,96 @@ | ||
| ## Loopster | ||
| Сервисная библиотека, которая обеспечивает выполнение сервисных процессов, следит за их зависаниями и при необходимости осуществляет перезапуск. | ||
| # Loopster | ||
|
|
||
| Loopster is a service library that provides mechanisms for executing and managing services, including monitoring their status and automatically restarting them when necessary. | ||
|
|
||
| ## Installation | ||
|
|
||
| To install Loopster, you can use pip: | ||
|
|
||
| ``` | ||
| pip install loopster | ||
| ``` | ||
|
|
||
| ## Usage | ||
|
|
||
| ### Basic Service Example | ||
|
|
||
| Here's an example of how to create and run a basic service using Loopster: | ||
|
|
||
| ```python | ||
| from loopster.hubs import base | ||
| from loopster.hubs.controllers import panic | ||
| from loopster.hubs.drivers import process | ||
| from loopster.services import softirq | ||
|
|
||
| class BasicService(softirq.SoftIrqService): | ||
| def _step(self): | ||
| print("Hello, world!") | ||
|
|
||
| driver = process.ProcessDriver() | ||
| controller = panic.PanicController() | ||
| hub = base.BaseHub(driver=driver, controller=controller) | ||
|
|
||
| hub.add_service(svc_class=BasicService, svc_kwargs={}) | ||
| hub.serve() | ||
| ``` | ||
|
|
||
| ### Nested Service Example with MySQLWrapper | ||
|
|
||
| Here's an example of how to use a nested service with the `mysqlwrapper` module: | ||
|
|
||
| ```python | ||
| from restalchemy.storage.sql import engines | ||
| from rooster.hubs.controllers import force_state | ||
| from loopster.hubs.drivers import process | ||
| from loopster.services import mysql | ||
| from loopster.services import softirq | ||
|
|
||
| class BasicService(softirq.SoftIrqService): | ||
| def _step(self): | ||
| print("Hello, world!") | ||
|
|
||
| hub = process.ProcessHub( | ||
| controller=force_state.AlwaysForceTargetStateController()) | ||
|
|
||
| hub.add_service( | ||
| svc_class=mysql.MySQLStorageWrapper, | ||
| svc_kwargs=dict( | ||
| nested_class=BasicService, | ||
| nested_kwargs=dict( | ||
| step_period=STEP_PERIOD, | ||
| ), | ||
| mysql_connection_url=engines.DBConnectionUrl(CONNECTION_URL) | ||
| ) | ||
| ) | ||
| ``` | ||
|
|
||
| ## Public Interface | ||
|
|
||
| ### Services | ||
|
|
||
| Loopster provides several built-in services, including: | ||
|
|
||
| - `SoftIrqService`: A service with a watchdog that runs in an infinite loop. | ||
| - `BjoernService`: A special server for Bjoern, which implements multiprocessing by itself. | ||
|
|
||
| ### Hubs | ||
| The `ProcessHub` class is used to manage multiple services using one strategy provided by the driver. It inherits from `SoftIrqService`, so it's a service too! | ||
|
|
||
| Hub provides a simple way to start and stop multiple services at once, as well as monitor their status. | ||
|
|
||
| #### Features | ||
|
|
||
| - **Signal Handling**: The `ProcessHub` can handle signals such as SIGHUP and SIGUSR1, allowing for graceful shutdowns and other terminal actions. | ||
| - **Multiprocessing Support**: By using the `multiprocessing` module, `ProcessHub` ensures that services run in separate processes, providing better isolation and resource management. | ||
| - **State Management**: The hub manages the state of each service, ensuring they are running as expected and automatically restarting them when necessary. | ||
|
|
||
| ### Controllers | ||
|
|
||
| Loopster includes different controllers that manage the state of services: | ||
|
|
||
| - `AlwaysForceTargetStateController`: A simple controller that always sets states in a loop. | ||
| - `PanicController`: A controller that stops managing on any problem. | ||
|
|
||
| ### Drivers | ||
|
|
||
| The `ProcessDriver` class is used to serve services as child processes. It provides methods for adding, removing, and setting the state of services. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.