Closed alexlibby closed 3 years ago
Try running pm2 logs
to see what is causing the error
This is what I get when running pm2
logs:
[TAILING] Tailing last 15 lines for [all] processes (change the value with --lines option)
/home/pi/.pm2/pm2.log last 15 lines:
PM2 | 2020-12-03T20:47:03: PM2 log: App [readnfc:2] online
PM2 | 2020-12-03T20:47:03: PM2 log: App [readnfc:2] exited with code [1] via signal [SIGINT]
PM2 | 2020-12-03T20:47:03: PM2 log: App [readnfc:2] starting in -fork mode-
PM2 | 2020-12-03T20:47:03: PM2 log: App [readnfc:2] online
PM2 | 2020-12-03T20:47:03: PM2 log: App [readnfc:2] exited with code [1] via signal [SIGINT]
PM2 | 2020-12-03T20:47:03: PM2 log: App [readnfc:2] starting in -fork mode-
PM2 | 2020-12-03T20:47:03: PM2 log: App [readnfc:2] online
PM2 | 2020-12-03T20:47:03: PM2 log: App [readnfc:2] exited with code [1] via signal [SIGINT]
PM2 | 2020-12-03T20:47:03: PM2 log: App [readnfc:2] starting in -fork mode-
PM2 | 2020-12-03T20:47:03: PM2 log: App [readnfc:2] online
PM2 | 2020-12-03T20:47:03: PM2 log: App [readnfc:2] exited with code [1] via signal [SIGINT]
PM2 | 2020-12-03T20:47:03: PM2 log: App [readnfc:2] starting in -fork mode-
PM2 | 2020-12-03T20:47:03: PM2 log: App [readnfc:2] online
PM2 | 2020-12-03T20:47:03: PM2 log: App [readnfc:2] exited with code [1] via signal [SIGINT]
PM2 | 2020-12-03T20:47:03: PM2 log: Script /home/pi/vinylemulator/readnfc.py had too many unstable restarts (16). Stopped. "errored"
/home/pi/.pm2/logs/readnfc-out.log last 15 lines:
/home/pi/.pm2/logs/npm-error.log last 15 lines:
0|npm | npm WARN npm npm does not support Node.js v10.21.0
0|npm | npm WARN npm You should probably upgrade to a newer version of node as we
0|npm | npm WARN npm can't make any promises that npm will work with this version.
0|npm | npm WARN npm Supported releases of Node.js are the latest release of 4, 6, 7, 8, 9.
0|npm | npm WARN npm You can find the latest version at https://nodejs.org/
0|npm | npm WARN npm npm does not support Node.js v10.21.0
0|npm | npm WARN npm You should probably upgrade to a newer version of node as we
0|npm | npm WARN npm can't make any promises that npm will work with this version.
0|npm | npm WARN npm Supported releases of Node.js are the latest release of 4, 6, 7, 8, 9.
0|npm | npm WARN npm You can find the latest version at https://nodejs.org/
0|npm | npm WARN npm npm does not support Node.js v10.21.0
0|npm | npm WARN npm You should probably upgrade to a newer version of node as we
0|npm | npm WARN npm can't make any promises that npm will work with this version.
0|npm | npm WARN npm Supported releases of Node.js are the latest release of 4, 6, 7, 8, 9.
0|npm | npm WARN npm You can find the latest version at https://nodejs.org/
/home/pi/.pm2/logs/npm-out.log last 15 lines:
0|npm | 2020-12-03T20:24:30.982Z INFO Could not find file /home/pi/node-sonos-http-api/settings.json
0|npm | 2020-12-03T20:24:31.409Z INFO Presets loaded: { example:
0|npm | { players:
0|npm | [ { roomName: 'Bathroom', volume: 10 },
0|npm | { roomName: 'Kitchen', volume: 10 },
0|npm | { roomName: 'Office', volume: 10 },
0|npm | { roomName: 'Bedroom', volume: 10 },
0|npm | { roomName: 'TV Room', volume: 15 } ],
0|npm | playMode: { shuffle: true, repeat: 'all', crossfade: false },
0|npm | pauseOthers: false },
0|npm | study:
0|npm | { players: [ { roomName: 'Study', volume: 10 } ],
0|npm | playMode: { shuffle: false, repeat: 'all', crossfade: false },
0|npm | pauseOthers: false } }
0|npm | 2020-12-03T20:24:33.376Z INFO http server listening on 0.0.0.0 port 5005
/home/pi/.pm2/logs/readnfc-error.log last 15 lines:
2|readnfc | File "/home/pi/vinylemulator/readnfc.py", line 2, in <module>
2|readnfc | import nfc
2|readnfc | ImportError: No module named nfc
2|readnfc | Traceback (most recent call last):
2|readnfc | File "/home/pi/vinylemulator/readnfc.py", line 2, in <module>
2|readnfc | import nfc
2|readnfc | ImportError: No module named nfc
2|readnfc | Traceback (most recent call last):
2|readnfc | File "/home/pi/vinylemulator/readnfc.py", line 2, in <module>
2|readnfc | import nfc
2|readnfc | ImportError: No module named nfc
2|readnfc | Traceback (most recent call last):
2|readnfc | File "/home/pi/vinylemulator/readnfc.py", line 2, in <module>
2|readnfc | import nfc
2|readnfc | ImportError: No module named nfc
The filepath given in the logs is correct - I'm wondering if this "no module" error is because I'm running puthon3, not python?
All of those npm warnings on process 0 are normal so ignore all that.
The warnings from readnfc are what is causing your problem. Python seems unable to import the nfc module. I suspect this is a python version issue (ie you have nfcpy installed for python3 but pm2 is trying to run it under python2 and is unable to find the module).
Deleting the existing readnfc process from pm2, run pm2 save
, rebooting and checking that it isn't running.
Then re-add it specifying that it should run on python3:
pm2 start vinylemulator/readnfc.py --interpreter python3
Make sure you run pm2 save
afterwards
Hi - thankyou for your help: the addition of the --interpreter parameter worked a treat! I'm able to play music using my NFC reader now :-)
Out of curiosity, is there any way to stop the music playing? I know it's possible by running the "playpause" URL, or the "clearqueue", but I'm thinking more along the lines of if I were to remove the card, it would automatically stop? I'm not a Python expert (or Linux one) by any means - is this feasible? I think it would make a great addition!
Hi - I've been trying out your project on RaspPi 4, and love the idea; I am however running into a small problem:
I've gotten as far as having the Spotify server run automatically on boot, but haven't been able to set the readnfc.py script to do the same. I can get Spotify to run as per step 9 , but when it comes to using pm2 to set the vinylemulator script to autoboot, I get this:
I can use
pm2 start vinylemulator/readnfc.py
to put it online, but if I reboot, I frequently get "stopped" show against this job! Any ideas as to how I can get around this please? The reader I'm using is an NFC ACR122 unit.I'm using python3 to run - it meant updating some of the commands listed in the tutorial, but otherwise it seems to run OK. If I run the readnfc.py script manually, it works OK - I do have to unplug the reader and plug it back in again though, before the reader decides to recognise my card :-)