mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2025-12-12 09:10:30 +08:00
receiving ustreamer signals
This commit is contained in:
parent
52e117df3c
commit
779a9f1d15
2
PKGBUILD
2
PKGBUILD
@ -47,7 +47,7 @@ depends=(
|
|||||||
patch
|
patch
|
||||||
sudo
|
sudo
|
||||||
raspberrypi-io-access
|
raspberrypi-io-access
|
||||||
"ustreamer>=1.9"
|
"ustreamer>=1.13"
|
||||||
)
|
)
|
||||||
makedepends=(python-setuptools)
|
makedepends=(python-setuptools)
|
||||||
source=("$url/archive/v$pkgver.tar.gz")
|
source=("$url/archive/v$pkgver.tar.gz")
|
||||||
|
|||||||
@ -47,6 +47,7 @@ kvmd:
|
|||||||
- "--unix-mode=0660"
|
- "--unix-mode=0660"
|
||||||
- "--exit-on-parent-death"
|
- "--exit-on-parent-death"
|
||||||
- "--process-name-prefix={process_name_prefix}"
|
- "--process-name-prefix={process_name_prefix}"
|
||||||
|
- "--notify-parent"
|
||||||
- "--no-log-colors"
|
- "--no-log-colors"
|
||||||
|
|
||||||
ipmi:
|
ipmi:
|
||||||
|
|||||||
@ -47,6 +47,7 @@ kvmd:
|
|||||||
- "--unix-mode=0660"
|
- "--unix-mode=0660"
|
||||||
- "--exit-on-parent-death"
|
- "--exit-on-parent-death"
|
||||||
- "--process-name-prefix={process_name_prefix}"
|
- "--process-name-prefix={process_name_prefix}"
|
||||||
|
- "--notify-parent"
|
||||||
- "--no-log-colors"
|
- "--no-log-colors"
|
||||||
|
|
||||||
ipmi:
|
ipmi:
|
||||||
|
|||||||
@ -48,6 +48,7 @@ kvmd:
|
|||||||
- "--unix-mode=0660"
|
- "--unix-mode=0660"
|
||||||
- "--exit-on-parent-death"
|
- "--exit-on-parent-death"
|
||||||
- "--process-name-prefix={process_name_prefix}"
|
- "--process-name-prefix={process_name_prefix}"
|
||||||
|
- "--notify-parent"
|
||||||
- "--no-log-colors"
|
- "--no-log-colors"
|
||||||
|
|
||||||
ipmi:
|
ipmi:
|
||||||
|
|||||||
@ -48,6 +48,7 @@ kvmd:
|
|||||||
- "--unix-mode=0660"
|
- "--unix-mode=0660"
|
||||||
- "--exit-on-parent-death"
|
- "--exit-on-parent-death"
|
||||||
- "--process-name-prefix={process_name_prefix}"
|
- "--process-name-prefix={process_name_prefix}"
|
||||||
|
- "--notify-parent"
|
||||||
- "--no-log-colors"
|
- "--no-log-colors"
|
||||||
|
|
||||||
ipmi:
|
ipmi:
|
||||||
|
|||||||
@ -52,6 +52,7 @@ kvmd:
|
|||||||
- "--unix-mode=0660"
|
- "--unix-mode=0660"
|
||||||
- "--exit-on-parent-death"
|
- "--exit-on-parent-death"
|
||||||
- "--process-name-prefix={process_name_prefix}"
|
- "--process-name-prefix={process_name_prefix}"
|
||||||
|
- "--notify-parent"
|
||||||
- "--no-log-colors"
|
- "--no-log-colors"
|
||||||
|
|
||||||
ipmi:
|
ipmi:
|
||||||
|
|||||||
@ -52,6 +52,7 @@ kvmd:
|
|||||||
- "--unix-mode=0660"
|
- "--unix-mode=0660"
|
||||||
- "--exit-on-parent-death"
|
- "--exit-on-parent-death"
|
||||||
- "--process-name-prefix={process_name_prefix}"
|
- "--process-name-prefix={process_name_prefix}"
|
||||||
|
- "--notify-parent"
|
||||||
- "--no-log-colors"
|
- "--no-log-colors"
|
||||||
|
|
||||||
ipmi:
|
ipmi:
|
||||||
|
|||||||
@ -56,6 +56,7 @@ kvmd:
|
|||||||
- "--unix-mode=0660"
|
- "--unix-mode=0660"
|
||||||
- "--exit-on-parent-death"
|
- "--exit-on-parent-death"
|
||||||
- "--process-name-prefix={process_name_prefix}"
|
- "--process-name-prefix={process_name_prefix}"
|
||||||
|
- "--notify-parent"
|
||||||
- "--no-log-colors"
|
- "--no-log-colors"
|
||||||
|
|
||||||
ipmi:
|
ipmi:
|
||||||
|
|||||||
@ -56,6 +56,7 @@ kvmd:
|
|||||||
- "--unix-mode=0660"
|
- "--unix-mode=0660"
|
||||||
- "--exit-on-parent-death"
|
- "--exit-on-parent-death"
|
||||||
- "--process-name-prefix={process_name_prefix}"
|
- "--process-name-prefix={process_name_prefix}"
|
||||||
|
- "--notify-parent"
|
||||||
- "--no-log-colors"
|
- "--no-log-colors"
|
||||||
|
|
||||||
ipmi:
|
ipmi:
|
||||||
|
|||||||
@ -49,6 +49,7 @@ kvmd:
|
|||||||
- "--unix-mode=0660"
|
- "--unix-mode=0660"
|
||||||
- "--exit-on-parent-death"
|
- "--exit-on-parent-death"
|
||||||
- "--process-name-prefix={process_name_prefix}"
|
- "--process-name-prefix={process_name_prefix}"
|
||||||
|
- "--notify-parent"
|
||||||
- "--no-log-colors"
|
- "--no-log-colors"
|
||||||
|
|
||||||
ipmi:
|
ipmi:
|
||||||
|
|||||||
@ -49,6 +49,7 @@ kvmd:
|
|||||||
- "--unix-mode=0660"
|
- "--unix-mode=0660"
|
||||||
- "--exit-on-parent-death"
|
- "--exit-on-parent-death"
|
||||||
- "--process-name-prefix={process_name_prefix}"
|
- "--process-name-prefix={process_name_prefix}"
|
||||||
|
- "--notify-parent"
|
||||||
- "--no-log-colors"
|
- "--no-log-colors"
|
||||||
|
|
||||||
ipmi:
|
ipmi:
|
||||||
|
|||||||
@ -29,6 +29,7 @@ from typing import List
|
|||||||
from typing import Dict
|
from typing import Dict
|
||||||
from typing import AsyncGenerator
|
from typing import AsyncGenerator
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
import aiohttp
|
import aiohttp
|
||||||
|
|
||||||
@ -197,13 +198,26 @@ class Streamer: # pylint: disable=too-many-instance-attributes
|
|||||||
}
|
}
|
||||||
|
|
||||||
async def poll_state(self) -> AsyncGenerator[Dict, None]:
|
async def poll_state(self) -> AsyncGenerator[Dict, None]:
|
||||||
|
notifier = aiotools.AioNotifier()
|
||||||
|
|
||||||
|
def signal_handler(*_: Any) -> None:
|
||||||
|
get_logger(0).info("Got SIGUSR2, checking the stream state ...")
|
||||||
|
asyncio.ensure_future(notifier.notify())
|
||||||
|
|
||||||
|
get_logger(0).info("Installing SIGUSR2 streamer handler ...")
|
||||||
|
asyncio.get_event_loop().add_signal_handler(signal.SIGUSR2, signal_handler)
|
||||||
|
|
||||||
prev_state: Dict = {}
|
prev_state: Dict = {}
|
||||||
while True:
|
while True:
|
||||||
state = await self.get_state()
|
state = await self.get_state()
|
||||||
if state != prev_state:
|
if state != prev_state:
|
||||||
yield state
|
yield state
|
||||||
prev_state = state
|
prev_state = state
|
||||||
await asyncio.sleep(self.__state_poll)
|
|
||||||
|
await asyncio.wait([
|
||||||
|
asyncio.sleep(self.__state_poll),
|
||||||
|
notifier.wait(),
|
||||||
|
], return_when=asyncio.FIRST_COMPLETED)
|
||||||
|
|
||||||
async def get_info(self) -> Dict:
|
async def get_info(self) -> Dict:
|
||||||
proc = await asyncio.create_subprocess_exec(
|
proc = await asyncio.create_subprocess_exec(
|
||||||
|
|||||||
@ -21,4 +21,5 @@ kvmd:
|
|||||||
- "--unix-mode=0666"
|
- "--unix-mode=0666"
|
||||||
- "--exit-on-parent-death"
|
- "--exit-on-parent-death"
|
||||||
- "--process-name-prefix={process_name_prefix}"
|
- "--process-name-prefix={process_name_prefix}"
|
||||||
|
- "--notify-parent"
|
||||||
- "--no-log-colors"
|
- "--no-log-colors"
|
||||||
|
|||||||
@ -29,4 +29,5 @@ kvmd:
|
|||||||
- "--unix-mode=0666"
|
- "--unix-mode=0666"
|
||||||
- "--exit-on-parent-death"
|
- "--exit-on-parent-death"
|
||||||
- "--process-name-prefix={process_name_prefix}"
|
- "--process-name-prefix={process_name_prefix}"
|
||||||
|
- "--notify-parent"
|
||||||
- "--no-log-colors"
|
- "--no-log-colors"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user