diff --git a/docs/source/platypush/plugins/application.rst b/docs/source/platypush/plugins/application.rst new file mode 100644 index 000000000..5c0d4696b --- /dev/null +++ b/docs/source/platypush/plugins/application.rst @@ -0,0 +1,5 @@ +``application`` +=============== + +.. automodule:: platypush.plugins.application + :members: diff --git a/docs/source/plugins.rst b/docs/source/plugins.rst index cadf898e7..86a68d5d3 100644 --- a/docs/source/plugins.rst +++ b/docs/source/plugins.rst @@ -8,6 +8,7 @@ Plugins platypush/plugins/adafruit.io.rst platypush/plugins/alarm.rst + platypush/plugins/application.rst platypush/plugins/arduino.rst platypush/plugins/assistant.echo.rst platypush/plugins/assistant.google.rst diff --git a/platypush/plugins/application/__init__.py b/platypush/plugins/application/__init__.py new file mode 100644 index 000000000..85a30559e --- /dev/null +++ b/platypush/plugins/application/__init__.py @@ -0,0 +1,31 @@ +from typing import Optional +from platypush.commands import CommandStream, RestartCommand, StopCommand +from platypush.config import Config +from platypush.plugins import Plugin, action + + +class ApplicationPlugin(Plugin): + """ + This plugin is used to control and inspect the application state. + """ + + @property + def _ctrl_sock(self) -> Optional[str]: + """ + :return: The path to the UNIX socket to control the application. + """ + return Config.get('ctrl_sock') # type: ignore + + @action + def stop(self): + """ + Stop the application. + """ + CommandStream(self._ctrl_sock).write(StopCommand()) + + @action + def restart(self): + """ + Restart the application. + """ + CommandStream(self._ctrl_sock).write(RestartCommand()) diff --git a/platypush/plugins/application/manifest.yaml b/platypush/plugins/application/manifest.yaml new file mode 100644 index 000000000..68cddacb7 --- /dev/null +++ b/platypush/plugins/application/manifest.yaml @@ -0,0 +1,6 @@ +manifest: + events: {} + install: + pip: [] + package: platypush.plugins.application + type: plugin