jishi / node-sonos-http-api

An HTTP API bridge for Sonos easing automation. Hostable on any node.js capable device, like a raspberry pi or similar.
http://jishi.github.io/node-sonos-http-api/
MIT License
1.83k stars 462 forks source link

Anyone know why CPU is constantly at 30% with this sonosserver running? #804

Closed jsiegenthaler closed 3 years ago

jsiegenthaler commented 3 years ago

I use the sonos http api server on my raspberry pi

The CPU sits stead at 30% with the server running. If I stop the sonosserver, the CPU goes to idle (0% to 1%)

Anyone know why the sonosserver has such a high CPU load?

jishi commented 3 years ago

Unless you have plenty of players that are all playing different music, you shouldn't see anything near those numbers unless you are hammering the API.

How are you using the api?

jsiegenthaler commented 3 years ago

Hi @jishi The api is used occasionally (1 or 2x per day) for text-to-speech via a command from my Apple HomeKit Otherwise it sits there idle, never plays music

jsiegenthaler commented 3 years ago

I'm wondering if the installation is mucked up. I might de-installl and reinstall it. The trouble is, there are no installation instructions ... I have to hunt through the web to find some...

jsiegenthaler commented 3 years ago

Hmmm... pm2 ls reports NPM uptime 4D, sonosserver uptime 1s... !!

jishi commented 3 years ago

I think there still is a bug if your players are turned off/changes IP while the API is running

https://github.com/jishi/node-sonos-http-api/issues/605

Could that be the cause? It would be evident in the output of the process if that were the case though.

jishi commented 3 years ago

Hmmm... pm2 ls reports NPM uptime 4D, sonosserver uptime 1s... !!

Sounds like it's constantly crashing. Some log output would be useful.

jsiegenthaler commented 3 years ago

Where is the right place to install it? I had it installed in /node_modules/sonos-http-api , but I'm moving it to /node-sonos-http-api-master of my pi user "pi"

jsiegenthaler commented 3 years ago

where does it write logs?

jishi commented 3 years ago

It outputs it in the terminal, if you run it with pm2 then pm2 will forward it to a file and you can view it with

pm2 logs

On Fri, 4 Jun 2021, 17:46 jsiegenthaler, @.***> wrote:

where does it write logs?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/jishi/node-sonos-http-api/issues/804#issuecomment-854827245, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAYE2I2NTJQ5U32CAEQYX4LTRDYNNANCNFSM46DARG6A .

jsiegenthaler commented 3 years ago

Solution:

  1. Delete folder /node_modules/sonosdiscovery/... (I installed stuff here in error)
  2. Delete folder /node_modules/sono-http-api/... (I installed stuff here in error)
  3. Stop all pm2 processes with pm2 stop all
  4. Delete the old pm2 process if applicable with pm2 delete 0 where 0 is the id
  5. Go to pi@raspberrypi:~/node-sonos-http-api-master folder
  6. Run npm audit
  7. Run npm install --production
  8. Add to pm2 with pm2 start npm --name "sonosserver" -- start
  9. Save the pm2 config with pm2 save
  10. Test by restarting Homebridge - OK, CPU at 1%
  11. Test by restarting raspberry pi - OK, CPU at 1%, pm2 ls shows sonosserver has restarted and is running on id 0 at 0% CPU
jsiegenthaler commented 3 years ago

bother, still happening

jishi commented 3 years ago

I need logs, and info on what rpi hardware you are running.

On Fri, 4 Jun 2021, 19:51 jsiegenthaler, @.***> wrote:

bother, still happening

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/jishi/node-sonos-http-api/issues/804#issuecomment-854902658, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAYE2I23OCWTFEI4P2MTQG3TREHBDANCNFSM46DARG6A .

jishi commented 3 years ago

I need logs. And which rpi revision you are runnin.

On Fri, 4 Jun 2021, 20:12 Jimmy Shimizu, @.***> wrote:

I need logs, and info on what rpi hardware you are running.

On Fri, 4 Jun 2021, 19:51 jsiegenthaler, @.***> wrote:

bother, still happening

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/jishi/node-sonos-http-api/issues/804#issuecomment-854902658, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAYE2I23OCWTFEI4P2MTQG3TREHBDANCNFSM46DARG6A .