Skip to content
This repository has been archived by the owner on Aug 30, 2020. It is now read-only.

rhasspy as a service #86

Closed
KiboOst opened this issue Dec 16, 2019 · 14 comments
Closed

rhasspy as a service #86

KiboOst opened this issue Dec 16, 2019 · 14 comments
Labels
bug Something isn't working enhancement New feature or request

Comments

@KiboOst
Copy link

KiboOst commented Dec 16, 2019

Actually rhasspy, as python env, is crashing a lot.

Would it be possible to set as a service, that would restart itself when it crash ? And also automatically start when rpi start ?

It would of course still talk with the console and restart when the console ask for it.

@koenvervloesem
Copy link
Contributor

Isn't this one of the use cases of Docker? If we add a health check to Rhasspy's Docker configuration, Docker is able to detect when Rhasspy crashes and restart it.

And when you say "crashing", you mean that Rhasspy really quits? Or do you mean that you're seeing stack traces in Rhasspy's output but it keeps running?

@KiboOst
Copy link
Author

KiboOst commented Dec 16, 2019

I'm not familiar with docker and guess a python venv is lighter/simpler ?

When I say crashing, yes it quit. It comes back to prompt and I have to restart it.
For example, I started it one hour ago to test things at work, I began to test the api/sentences but now it is crached, curl error 7, nobody there, boom ...

I may try to start it with systemd to see if it works.

@koenvervloesem
Copy link
Contributor

For example, I started it one hour ago to test things at work, I began to test the api/sentences but now it is crached, curl error 7, nobody there, boom ...

Can you open a separate issue with specific information about this?

@KiboOst
Copy link
Author

KiboOst commented Dec 16, 2019

I'm not at home and have no access to it so I can't see what happened.
Ever reported several usual issues here : #74
And got a lot of ever reported training returned -1 errors.

@mathquis
Copy link
Contributor

Running Rhasspy as a systemd service should be pretty straightforward:
https://doc.ubuntu-fr.org/creer_un_service_avec_systemd

If you manage to get a systemd service running, you can ask @synesthesiam to include it in this repo via a pull request for others to enjoy :)

@mathquis
Copy link
Contributor

mathquis commented Dec 16, 2019

I noted that Rhasspy consume more and more memory with each request (training, transcription, parsing, etc.) and never releases it (which may be ok on Linux systems).

I have a Rhasspy docker container running using almost 1GB of memory (at startup it only consumes 200M) and increasing with each training/request.

Maybe there is a memory leak somewhere that make Rhasspy crash after multiple requests with the limited Rpi resources?

@richardmward
Copy link

I have a Rhasspy docker container running using almost 1GB of memory (at startup it only consumes 200M)

I too have noticed Rhasspy seems to gradually consume all available memory - using docker on an rpi4. I can't say I've noticed a pattern as to when it occurs, but thought i'd add that it isn't a unique issue (I wondered if it was something I had done!).

@KiboOst
Copy link
Author

KiboOst commented Dec 17, 2019

For those familiar with linux/systemd, would this work ?

sudo nano /etc/systemd/system/rhasspy.service

then:

[Unit]
Description=Rhasspy Core

[Service]
ExecStart=/home/pi/rhasspy/run-venv.sh --profile fr
WorkingDirectory=/home/pi/rhasspy
Restart=always
RestartSec=5

[Install]
WantedBy=multi-user.target

Then I can:
restart /stop : sudo systemctl restart rhasspy.service
get log: journalctl -u rhasspy.service

Sounds right ?

@KiboOst
Copy link
Author

KiboOst commented Dec 17, 2019

Doesn't work.

Rhasspt start but decoder doesn't work:

File "/home/pi/rhasspy/.venv/lib/python3.7/site-packages/pocketsphinx/pocketsphinx.py", line 273, in __init__
this = _pocketsphinx.new_Decoder(*args)
RuntimeError: new_Decoder returned -1

File "/home/pi/rhasspy/rhasspy/intent.py", line 195, in in_loaded
self.load_graph()
File "/home/pi/rhasspy/rhasspy/intent.py", line 241, in load_graph
with open(graph_path, "r") as graph_file:
FileNotFoundError: [Errno 2] No such file or directory: 'profiles/fr/intent.json'

But wakeword get detected, but no intent recognized. And on first time, without busy error lol !

@synesthesiam
Copy link
Owner

This must be due to needing absolute paths for everything in a systemd service. Can you set a working directory somehow?

@synesthesiam synesthesiam added the enhancement New feature or request label Dec 18, 2019
@synesthesiam
Copy link
Owner

I have a Rhasspy docker container running using almost 1GB of memory (at startup it only consumes 200M)

I too have noticed Rhasspy seems to gradually consume all available memory - using docker on an rpi4. I can't say I've noticed a pattern as to when it occurs, but thought i'd add that it isn't a unique issue (I wondered if it was something I had done!).

This is really concerning. Anyone know of some good python performance tools we could use to narrow down the problem?

@synesthesiam synesthesiam added the bug Something isn't working label Dec 18, 2019
@KiboOst
Copy link
Author

KiboOst commented Dec 18, 2019

This must be due to needing absolute paths for everything in a systemd service. Can you set a working directory somehow?

I did:

ExecStart=/home/pi/rhasspy/run-venv.sh --profile fr
WorkingDirectory=/home/pi/rhasspy

@UnderpantsGnome
Copy link

This is a working systemd unit from my setup. Note that I have rhasspy installed in ~/apps so you will need to update the WorkingDirectory for your install.

[Unit]
Description=Rhasspy
After=syslog.target network.target

[Service]
Type=simple
WorkingDirectory=/home/pi/apps/rhasspy
ExecStart=/bin/bash -lc './run-venv.sh --profile en'
User=pi
Group=staff
UMask=0002

RestartSec=1
Restart=on-failure

StandardOutput=syslog
StandardError=syslog

SyslogIdentifier=rhasspy

[Install]
WantedBy=multi-user.target

@synesthesiam
Copy link
Owner

Thanks @UnderpantsGnome! I've added a section to the documentation based on your answer here :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

6 participants