Skip to content
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

feat: add hivemind #122

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions build_raspOVOS.sh
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ uv pip install --no-progress --pre ovos-phal[extras,linux] ovos-PHAL-plugin-dots
echo "Installing OVOS Spotify..."
uv pip install --no-progress --pre ovos-media-plugin-spotify ovos-skill-spotify

echo "Installing HiveMind..."
# TODO deltachat/matrix bridhes + hivemind help alias
uv pip install --no-progress --pre hivemind-core

# some skills import from these libs and dont have them as dependencies
# just until that is fixed...
echo "Installing deprecated OVOS packages for compat..."
Expand All @@ -175,6 +179,7 @@ cp -v /mounted-github-repo/services/ovos-systemd-audio /usr/libexec/ovos-systemd
cp -v /mounted-github-repo/services/ovos-systemd-listener /usr/libexec/ovos-systemd-listener
cp -v /mounted-github-repo/services/ovos-systemd-phal /usr/libexec/ovos-systemd-phal
cp -v /mounted-github-repo/services/ovos-systemd-gui /usr/libexec/ovos-systemd-gui
cp -v /mounted-github-repo/services/ovos-systemd-hivemind /usr/libexec/ovos-systemd-hivemind
cp -v /mounted-github-repo/services/ovos-librespot /usr/libexec/ovos-librespot

mkdir -p /home/$USER/.config/systemd/user/
Expand All @@ -185,6 +190,7 @@ cp -v /mounted-github-repo/services/ovos-audio.service /home/$USER/.config/syste
cp -v /mounted-github-repo/services/ovos-listener.service /home/$USER/.config/systemd/user/
cp -v /mounted-github-repo/services/ovos-phal.service /home/$USER/.config/systemd/user/
cp -v /mounted-github-repo/services/ovos-gui.service /home/$USER/.config/systemd/user/
cp -v /mounted-github-repo/services/hivemind-core.service /home/$USER/.config/systemd/user/
cp -v /mounted-github-repo/services/ovos-ggwave.service /home/$USER/.config/systemd/user/
cp -v /mounted-github-repo/services/ovos-spotify.service /home/$USER/.config/systemd/user/

Expand All @@ -201,6 +207,7 @@ ln -s /home/$USER/.config/systemd/user/ovos-audio.service /home/$USER/.config/sy
ln -s /home/$USER/.config/systemd/user/ovos-listener.service /home/$USER/.config/systemd/user/default.target.wants/ovos-listener.service
ln -s /home/$USER/.config/systemd/user/ovos-phal.service /home/$USER/.config/systemd/user/default.target.wants/ovos-phal.service
ln -s /home/$USER/.config/systemd/user/ovos-gui.service /home/$USER/.config/systemd/user/default.target.wants/ovos-gui.service
ln -s /home/$USER/.config/systemd/user/hivemind-core.service /home/$USER/.config/systemd/user/default.target.wants/hivemind-core.service
ln -s /home/$USER/.config/systemd/user/ovos-ggwave.service /home/$USER/.config/systemd/user/default.target.wants/ovos-ggwave.service
ln -s /home/$USER/.config/systemd/user/ovos-spotify.service /home/$USER/.config/systemd/user/default.target.wants/ovos-spotify.service

Expand Down
20 changes: 20 additions & 0 deletions services/hivemind-core.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[Unit]
Description=HiveMind core
PartOf=ovos.service
After=ovos.service
After=ovos-messagebus.service

[Service]
Type=notify
Group=ovos
UMask=002
ExecStart=%h/.venvs/ovos/bin/python /usr/libexec/ovos-systemd-hivemind
TimeoutStartSec=10m
TimeoutStopSec=1m
Restart=on-failure
StartLimitInterval=5min
StartLimitBurst=4

[Install]
WantedBy=ovos.service

20 changes: 17 additions & 3 deletions services/ovos-systemd-admin-phal
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,32 @@
##########################################################################
import sdnotify
from ovos_PHAL.admin import main
from ovos_utils.log import LOG

n = sdnotify.SystemdNotifier()


def notify_started():
n.notify('STARTED=1')
LOG.info("OVOS Admin PHAL service started!")


def notify_ready():
n.notify('READY=1')
print('Startup of admin PHAL service complete')
LOG.info('Startup of Admin PHAL service complete')


def notify_stopping():
n.notify('STOPPING=1')
print('Stopping the admin PHAL service')
LOG.info('Stopping the Admin PHAL service')


main(ready_hook=notify_ready, stopping_hook=notify_stopping)
if __name__ == "__main__":
try:
main(started_hook=notify_started,
ready_hook=notify_ready,
stopping_hook=notify_stopping)
except Exception as e:
LOG.error(f"OVOS Admin PHAL Service encountered an error: {e}")
n.notify(f'ERRNO=1')
exit(1)
22 changes: 19 additions & 3 deletions services/ovos-systemd-audio
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,36 @@
# See the License for the specific language governing permissions and
# limitations under the License.
##########################################################################
import sys

import sdnotify
from ovos_audio.__main__ import main
from ovos_utils.log import LOG

n = sdnotify.SystemdNotifier()


def notify_started():
n.notify('STARTED=1')
LOG.info("OVOS Audio service started!")


def notify_ready():
n.notify('READY=1')
print('Startup of OVOS Audio service complete')
LOG.info('Startup of OVOS Audio service complete')


def notify_stopping():
n.notify('STOPPING=1')
print('Stopping the OVOS Audio service')
LOG.info('Stopping the OVOS Audio service')


main(ready_hook=notify_ready, stopping_hook=notify_stopping)
if __name__ == "__main__":
try:
main(started_hook=notify_started,
ready_hook=notify_ready,
stopping_hook=notify_stopping)
except Exception as e:
LOG.error(f"Service encountered an error: {e}")
n.notify(f'ERRNO=1')
sys.exit(1)
20 changes: 17 additions & 3 deletions services/ovos-systemd-gui
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,32 @@
##########################################################################
import sdnotify
from ovos_gui.__main__ import main
from ovos_utils.log import LOG

n = sdnotify.SystemdNotifier()


def notify_started():
n.notify('STARTED=1')
LOG.info("OVOS GUI service started!")


def notify_ready():
n.notify('READY=1')
print('Startup of OVOS GUI service complete')
LOG.info('Startup of OVOS GUI service complete')


def notify_stopping():
n.notify('STOPPING=1')
print('Stopping the OVOS GUI service')
LOG.info('Stopping the OVOS GUI service')


main(ready_hook=notify_ready, stopping_hook=notify_stopping)
if __name__ == "__main__":
try:
main(started_hook=notify_started,
ready_hook=notify_ready,
stopping_hook=notify_stopping)
except Exception as e:
LOG.error(f"OVOS GUI Service encountered an error: {e}")
n.notify(f'ERRNO=1')
exit(1)
38 changes: 38 additions & 0 deletions services/ovos-systemd-hivemind.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import sdnotify
from hivemind_core.service import HiveMindService
from ovos_utils.log import LOG

n = sdnotify.SystemdNotifier()


def on_ready():
n.notify('READY=1')
LOG.info("hivemind-core service ready!")


def on_started():
n.notify('STARTED=1')
LOG.info("hivemind-core service started!")


def on_stopping():
n.notify('STOPPING=1')
LOG.info("hivemind-core is shutting down...")


def main():
service = HiveMindService(
started_hook=on_started,
ready_hook=on_ready,
stopping_hook=on_stopping)

try:
service.run()
except Exception as e:
LOG.error(f"hivemind-core encountered an error: {e}")
n.notify(f'ERRNO=1')
exit(1)


if __name__ == "__main__":
main()
24 changes: 19 additions & 5 deletions services/ovos-systemd-listener
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,32 @@

import sdnotify
from ovos_dinkum_listener.__main__ import main
from ovos_utils.log import LOG

n = sdnotify.SystemdNotifier()


def notify_started():
n.notify('STARTED=1')
LOG.info("OVOS Listener service started!")


def notify_ready():
n.notify('READY=1')
print('Startup of Mycroft Voice service complete')
LOG.info('Startup of OVOS Listener service complete')


def notify_stopping():
n.notify('STOPPING=1')
print('Stopping the Mycroft Voice service')


main(ready_hook=notify_ready, stopping_hook=notify_stopping)
LOG.info('Stopping the OVOS Listener service')


if __name__ == "__main__":
try:
main(started_hook=notify_started,
ready_hook=notify_ready,
stopping_hook=notify_stopping)
except Exception as e:
LOG.error(f"OVOS Listener Service encountered an error: {e}")
n.notify(f'ERRNO=1')
exit(1)
20 changes: 17 additions & 3 deletions services/ovos-systemd-messagebus
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,32 @@
##########################################################################
import sdnotify
from ovos_messagebus.__main__ import main
from ovos_utils.log import LOG

n = sdnotify.SystemdNotifier()


def notify_started():
n.notify('STARTED=1')
LOG.info("OVOS Messagebus service started!")


def notify_ready():
n.notify('READY=1')
print('Startup of OVOS Messagebus service complete')
LOG.info('Startup of OVOS Messagebus service complete')


def notify_stopping():
n.notify('STOPPING=1')
print('Stopping the OVOS Messagebus service')
LOG.info('Stopping the OVOS Messagebus service')


main(ready_hook=notify_ready, stopping_hook=notify_stopping)
if __name__ == "__main__":
try:
main(started_hook=notify_started,
ready_hook=notify_ready,
stopping_hook=notify_stopping)
except Exception as e:
LOG.error(f"OVOS Messagebus Service encountered an error: {e}")
n.notify(f'ERRNO=1')
exit(1)
20 changes: 17 additions & 3 deletions services/ovos-systemd-phal
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,32 @@
##########################################################################
import sdnotify
from ovos_PHAL.__main__ import main
from ovos_utils.log import LOG

n = sdnotify.SystemdNotifier()


def notify_started():
n.notify('STARTED=1')
LOG.info("OVOS PHAL service started!")


def notify_ready():
n.notify('READY=1')
print('Startup of OVOS PHAL service complete')
LOG.info('Startup of OVOS PHAL service complete')


def notify_stopping():
n.notify('STOPPING=1')
print('Stopping the OVOS PHAL service')
LOG.info('Stopping the OVOS PHAL service')


main(ready_hook=notify_ready, stopping_hook=notify_stopping)
if __name__ == "__main__":
try:
main(started_hook=notify_started,
ready_hook=notify_ready,
stopping_hook=notify_stopping)
except Exception as e:
LOG.error(f"OVOS PHAL Service encountered an error: {e}")
n.notify(f'ERRNO=1')
exit(1)
20 changes: 17 additions & 3 deletions services/ovos-systemd-skills
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,32 @@
##########################################################################
import sdnotify
from ovos_core.__main__ import main
from ovos_utils.log import LOG

n = sdnotify.SystemdNotifier()


def notify_started():
n.notify('STARTED=1')
LOG.info("OVOS Skills service started!")


def notify_ready():
n.notify('READY=1')
print('Startup of OVOS Skills service complete')
LOG.info('Startup of OVOS Skills service complete')


def notify_stopping():
n.notify('STOPPING=1')
print('Stopping the OVOS Skills service')
LOG.info('Stopping the OVOS Skills service')


main(ready_hook=notify_ready, stopping_hook=notify_stopping)
if __name__ == "__main__":
try:
main(started_hook=notify_started,
ready_hook=notify_ready,
stopping_hook=notify_stopping)
except Exception as e:
LOG.error(f"OVOS Skills Service encountered an error: {e}")
n.notify(f'ERRNO=1')
exit(1)