Rhasspy as a service (without Docker)

In the documentation it says you can install Rhasspy in Debian,

Now you can run rhasspy from the command-line:

$ rhasspy --profile en

and access the web interface at http://localhost:12101

This is great for testing, but can Rhasspy be run headless - as a service ? Is this why all examples use Docker, even on a dedicated low powered RasPi Zero ?

Maybe I’m being obsessive here, but on a dedicated low-speed RasPi Zero Rhasspy satellite I don’t see a need for Docker or venv to sandbox applications if there is nothing else running in that machine to protect.

It is possible to run Rhasspy as a service; but there were 3 problems:

  1. shutdown and reboot operations require us to enter our sudo password at the (now non-existent) terminal. Given that this is a dedicated voice assistant satellite and not connected to the interweb, I can probably put up with authorising the user “pi” to have root privileges.
sudo visudo

at end of the file, add

pi ALL = NOPASSWD: ALL

  1. setup the service, by
sudo nano /etc/systemd/system/rhasspy.service

[Unit]
Description=Rhasspy Autostart
After=network-online.target

[Service]
Type=simple
User=pi
WorkingDirectory=/home/pi
ExecStart=/bin/bash -lc ‘/usr/bin/rhasspy --profile en 2>&1 | cat’
StandardOutput=inherit
StandardError=inherit
Restart=always
RestartSec=5

[Install]
WantedBy=multi-user.target

next tell linux to automatically start the service on reboot

sudo systemctl enable rhasspy

and we can start it now

sudo systemctl daemon-reload
sudo systemctl start rhasspy
  1. Linux system services handle stdout differently from command line. If we had used “ExecStart=rhasspy --profile en” above, we would have got “spawnerr: unknown error making dispatchers for ‘microphone’: ENXIO” errors. See Sherlock - Offline Voice Assistant project for a description

And, so far, this seems to be working for me.

Hi there,

imo running any service with root privileges is not recommended, so here’s my rhasspy.service used on a headless debian (x64) machine:

[Unit]
Description=Rhasspy Service
After=syslog.target network.target mosquitto.service

[Service]
Type=simple
# for command, see https://github.com/rhasspy/rhasspy/issues/42#issuecomment-711472505
ExecStart=/bin/bash -c 'rhasspy -p de --user-profiles /opt/rhasspy/profiles 2>&1 | cat'
WorkingDirectory=/opt/rhasspy
User=rhasspy
Group=audio
RestartSec=10
Restart=on-failure
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=rhasspy

[Install]
WantedBy=multi-user.target

User rhasspy and working dir have to be added manually, obviously, and user rhasspy is added in group audio (despite the fact no direct audio hardware is used).
Suggestions to improve it are welcome, as this also is some kind of copy/paste solution…