mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2025-12-13 01:30:31 +08:00
refactoring
This commit is contained in:
parent
5589ecbac4
commit
c0ee171edb
@ -32,7 +32,12 @@ kvmd:
|
||||
|
||||
shutdown_delay: 10.0
|
||||
|
||||
cmd: "/usr/bin/mjpg_streamer -i 'input_uvc.so -d /dev/video0 -e 2 -y -n -r 720x576' -o 'output_http.so -l localhost -p 8082'"
|
||||
cmd:
|
||||
- "/usr/bin/mjpg_streamer"
|
||||
- "-i"
|
||||
- "input_uvc.so -d /dev/video0 -e 2 -y -n -r 720x576"
|
||||
- "-o"
|
||||
- "output_http.so -l localhost -p 8082"
|
||||
|
||||
logging:
|
||||
version: 1
|
||||
|
||||
@ -30,7 +30,7 @@ def main() -> None:
|
||||
cap_power=int(config["video"]["pinout"]["cap"]),
|
||||
conv_power=int(config["video"]["pinout"]["conv"]),
|
||||
sync_delay=float(config["video"]["sync_delay"]),
|
||||
cmd=str(config["video"]["cmd"]),
|
||||
cmd=list(map(str, config["video"]["cmd"])),
|
||||
loop=loop,
|
||||
)
|
||||
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import asyncio
|
||||
import asyncio.subprocess
|
||||
|
||||
from typing import List
|
||||
from typing import Optional
|
||||
|
||||
from .logging import get_logger
|
||||
@ -15,10 +16,12 @@ class Streamer: # pylint: disable=too-many-instance-attributes
|
||||
cap_power: int,
|
||||
conv_power: int,
|
||||
sync_delay: float,
|
||||
cmd: str,
|
||||
cmd: List[str],
|
||||
loop: asyncio.AbstractEventLoop,
|
||||
) -> None:
|
||||
|
||||
assert cmd, cmd
|
||||
|
||||
self.__cap_power = gpio.set_output(cap_power)
|
||||
self.__conv_power = (gpio.set_output(conv_power) if conv_power > 0 else conv_power)
|
||||
self.__sync_delay = sync_delay
|
||||
@ -60,8 +63,8 @@ class Streamer: # pylint: disable=too-many-instance-attributes
|
||||
while True: # pylint: disable=too-many-nested-blocks
|
||||
proc: Optional[asyncio.subprocess.Process] = None # pylint: disable=no-member
|
||||
try:
|
||||
proc = await asyncio.create_subprocess_shell(
|
||||
self.__cmd,
|
||||
proc = await asyncio.create_subprocess_exec(
|
||||
*self.__cmd,
|
||||
stdout=asyncio.subprocess.PIPE,
|
||||
stderr=asyncio.subprocess.STDOUT,
|
||||
)
|
||||
@ -105,7 +108,7 @@ class Streamer: # pylint: disable=too-many-instance-attributes
|
||||
if proc.returncode is not None:
|
||||
raise
|
||||
await proc.wait()
|
||||
get_logger().info("Streamer killed: pid=%d; retcode=%d")
|
||||
get_logger().info("Streamer killed: pid=%d; retcode=%d", proc.pid, proc.returncode)
|
||||
except Exception:
|
||||
if proc.returncode is None:
|
||||
get_logger().exception("Can't kill streamer pid=%d", proc.pid)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user