diff --git a/build_raspOVOS.sh b/build_raspOVOS.sh index 097c2a53..d92fe469 100644 --- a/build_raspOVOS.sh +++ b/build_raspOVOS.sh @@ -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..." @@ -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/ @@ -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/ @@ -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 diff --git a/services/hivemind-core.service b/services/hivemind-core.service new file mode 100644 index 00000000..8aac7ed9 --- /dev/null +++ b/services/hivemind-core.service @@ -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 + diff --git a/services/ovos-systemd-admin-phal b/services/ovos-systemd-admin-phal index 7ebd2df1..f92ee4b1 100644 --- a/services/ovos-systemd-admin-phal +++ b/services/ovos-systemd-admin-phal @@ -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) diff --git a/services/ovos-systemd-audio b/services/ovos-systemd-audio index 14e66f32..abc68822 100644 --- a/services/ovos-systemd-audio +++ b/services/ovos-systemd-audio @@ -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) diff --git a/services/ovos-systemd-gui b/services/ovos-systemd-gui index 1bb8bedf..ce85101a 100644 --- a/services/ovos-systemd-gui +++ b/services/ovos-systemd-gui @@ -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) diff --git a/services/ovos-systemd-hivemind.py b/services/ovos-systemd-hivemind.py new file mode 100644 index 00000000..27e5de92 --- /dev/null +++ b/services/ovos-systemd-hivemind.py @@ -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() diff --git a/services/ovos-systemd-listener b/services/ovos-systemd-listener index fc0c2b16..26167544 100644 --- a/services/ovos-systemd-listener +++ b/services/ovos-systemd-listener @@ -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) diff --git a/services/ovos-systemd-messagebus b/services/ovos-systemd-messagebus index fce55853..fa7d970c 100644 --- a/services/ovos-systemd-messagebus +++ b/services/ovos-systemd-messagebus @@ -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) diff --git a/services/ovos-systemd-phal b/services/ovos-systemd-phal index fb29d280..8d7805f6 100644 --- a/services/ovos-systemd-phal +++ b/services/ovos-systemd-phal @@ -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) diff --git a/services/ovos-systemd-skills b/services/ovos-systemd-skills index 73199790..aecf9ab3 100644 --- a/services/ovos-systemd-skills +++ b/services/ovos-systemd-skills @@ -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)