Metadata-Version: 2.1
Name: supervisor-gateway
Version: 0.3.2
Summary: An RESTful supervisor gateway with paginated and cached process info
Home-page: https://github.com/ppd0705/supervisor-gateway
Author: ppd0705
Author-email: ppd0705@icloud.com
License: UNKNOWN
Platform: UNKNOWN
Classifier: Intended Audience :: Developers
Classifier: Operating System :: POSIX
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Topic :: System :: Boot
Classifier: Topic :: System :: Monitoring
Classifier: Topic :: System :: Systems Administration
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Requires-Dist: aiohttp
Requires-Dist: aiohttp-xmlrpc (>=1.5.0)
Requires-Dist: pydantic
Requires-Dist: starlette
Requires-Dist: fastapi (>=0.75.0)
Requires-Dist: uvicorn (>=0.17.6)
Provides-Extra: lint
Requires-Dist: autoflake (>=1.4.0) ; extra == 'lint'
Requires-Dist: isort (>=5.10.0) ; extra == 'lint'
Requires-Dist: black (>=22.1.0) ; extra == 'lint'
Requires-Dist: flake8 (>=4.0.0) ; extra == 'lint'
Provides-Extra: publish
Requires-Dist: twine (==3.8.0) ; extra == 'publish'
Requires-Dist: wheel (==0.37.1) ; extra == 'publish'
Provides-Extra: test
Requires-Dist: pytest (>=7.1.0) ; extra == 'test'
Requires-Dist: pytest-mock (>=3.7.0) ; extra == 'test'
Requires-Dist: coverage (>=6.3.2) ; extra == 'test'
Requires-Dist: pytest-asyncio (>=0.18.2) ; extra == 'test'
Requires-Dist: httpx (>=0.22.0) ; extra == 'test'

<p align="center">
<a href="https://github.com/ppd0705/supervisor-gateway/actions">
    <img src="https://github.com/ppd0705/supervisor-gateway/workflows/Test%20Suite/badge.svg" alt="Test Suite">
</a>
<a href="https://pypi.org/project/supervisor-gateway" target="_blank">
    <img src="https://img.shields.io/pypi/v/supervisor-gateway?color=%2334D058&label=pypi%20package" alt="Package version">
</a>
<a href="https://pypi.org/project/supervisor-gateway" target="_blank">
    <img src="https://img.shields.io/pypi/pyversions/supervisor-gateway.svg?color=%2334D058" alt="Supported Python versions">
</a>
</p>

# supervisor-gateway

A RESTful supervisor gateway with paginated and cached process info

## Features
- RESTful API to `supevisord` support
- A `eventlistener` role for events subscription  
- Cached status API with pagination 

## Architecture

<a href="https://github.com/ppd0705/supervisor-gateway">
    <img src="https://github.com/ppd0705/supervisor-gateway/blob/master/architecture.png" alt="supervisor-gateway">
</a>

## Install

from pypi

```shell
pip install supervisor-gateway
```

or install locally

```shell
make install
```

## Usage

`supervisor-gateway` running as child process of supervisord, there is a [supervisor config example](config/supervisor/supervisor_gateway.conf)

```ini
[eventlistener:supervisor_gateway]
command = python -m supervisor_gateway
events = PROCESS_STATE,SUPERVISOR_STATE_CHANGE,PROCESS_GROUP
environment = SG_LOG_LEVEL="DEBUG",SG_RPC="http://localhost:9011/RPC2",SG_LOG_FILE=
              "supervisor_gateway.log",SG_HOST="localhost",SG_PORT="1234"
stderr_logfile = supervisor_gateway.err.log
stderr_logfile_maxbytes = 10MB
stderr_logfile_backups = 2
buffer_size = 1024
```

some supported environments blow:
- SG_HOST: listen host
- SG_PORT: listen port
- SG_RPC: supervisord rpc url
- SG_LOG_LEVEL: log level
- SG_LOG_FILE: log file

update supervisor conf
```shell
supervisorctl update supervisor_gateway
```

check it 
```shell
curl  http://localhost:1234/rpc/state  
```

interact with api document in the browser [http://localhost:1234/docs](http://localhost:1234/docs)

## TODO
- [x] Add unit test
- [x] Add more API
- [x] Add API documents

## License

Distributed under the MIT License. See [LICENSE](LICENSE) for more information.

## Acknowledgments

- [supervisor](https://github.com/Supervisor/supervisor)
- [multivisor](https://github.com/tiagocoutinho/multivisor)
- [aioconsole](https://github.com/vxgmichel/aioconsole)
- [aiohttp-xmlrpc](https://github.com/mosquito/aiohttp-xmlrpc)
- [fastapi](https://github.com/tiangolo/fastapi)

