Node-red looping on start raspberry pi - raspberry-pi

I was using node-red in my raspberry pi normally until get the brillant idea to install new nodes.
Now, I am unable to start it. The node-red is in loop when starting.
> Start Node-RED Once Node-RED has started, point a browser at
> http://192.168.0.113:1880 On Pi Node-RED works better with the Firefox
> or Chrome browser Use node-red-stop to
> stop Node-RED Use node-red-start to start
> Node-RED again Use node-red-log to view
> the recent log output Use sudo systemctl enable nodered.service to
> autostart Node-RED at every boot Use sudo systemctl disable
> nodered.service to disable autostart on boot To find more nodes and
> example flows - go to http://flows.nodered.org Starting as a systemd
> service. Started Node-RED graphical event wiring tool.. 10 Jan
> 00:29:50 - [info] Welcome to Node-RED
> =================== 10 Jan 00:29:50 - [info] Node-RED version: v0.17.5 10 Jan 00:29:50 - [info] Node.js version: v6.12.3 10 Jan 00:29:50 -
> [info] Linux 4.9.35-v7+ arm LE 10 Jan 00:29:51 - [info] Loading
> palette nodes [../deps/mpg123/src/output/alsa.c:165] error: cannot
> open device default node: pcm_params.c:2286: snd_pcm_hw_refine:
> Assertion `pcm && params' failed. nodered.service: main process
> exited, code=killed, status=6/ABRT Unit nodered.service entered failed
> state. nodered.service holdoff time over, scheduling restart. Stopping
> Node-RED graphical event wiring tool.... Starting Node-RED graphical
> event wiring tool.... Started Node-RED graphical event wiring tool..
> 10 Jan 00:29:57 - [info] Welcome to Node-RED
> =================== 10 Jan 00:29:57 - [info] Node-RED version: v0.17.5 10 Jan 00:29:57 - [info] Node.js version: v6.12.3 10 Jan 00:29:57 -
> [info] Linux 4.9.35-v7+ arm LE 10 Jan 00:29:58 - [info] Loading
> palette nodes [../deps/mpg123/src/output/alsa.c:165] error: cannot
> open device default node: pcm_params.c:2286: snd_pcm_hw_refine:
> Assertion `pcm && params' failed. nodered.service: main process
> exited, code=killed, status=6/ABRT Unit nodered.service entered failed
> state. nodered.service holdoff time over, scheduling restart. Stopping
> Node-RED graphical event wiring tool.... Starting Node-RED graphical
> event wiring tool.... Started Node-RED graphical event wiring tool..
> 10 Jan 00:30:04 - [info] Welcome to Node-RED
> =================== 10 Jan 00:30:04 - [info] Node-RED version: v0.17.5 10 Jan 00:30:04 - [info] Node.js version: v6.12.3 10 Jan 00:30:04 -
> [info] Linux 4.9.35-v7+ arm LE 10 Jan 00:30:05 - [info] Loading
> palette nodes

Go to the directory /home/pi/.node-red and open the package.json file.
It should contain a dependencies section that lists the extra nodes you installed (assuming you did so via the Palette Manager in the editor). Identify any nodes related to playing audio - the crashing error is related to trying to use the mpg123 command line tool for playing audio files.
Then on the command line, run npm remove NAME-OF-MODULE --save.
Node-RED should then restart cleanly.

Related

k3s multimaster with embedded etcd is failing to form join cluster

I have two fresh ubuntu VM(s)
VM-1 (65.0.54.158)
VM-2 (65.2.136.2)
I am trying to set up a HA k3s cluster with embedded ETCD. I am referring to the official document
Here is what I have executed on VM-1
curl -sfL https://get.k3s.io | K3S_TOKEN=AtJMEyWR8pE3HR4RWgT6IsqglOkBm0sLC4n0aDBkng9VE1uqyNevR6oCMNCqQNaF sh -s - server --cluster-init
Here is the response from VM-1
curl -sfL https://get.k3s.io | K3S_TOKEN=AtJMEyWR8pE3HR4RWgT6IsqglOkBm0sLC4n0aDBkng9VE1uqyNevR6oCMNCqQNaF sh -s - server --cluster-init
[INFO] Finding release for channel stable
[INFO] Using v1.24.4+k3s1 as release
[INFO] Downloading hash https://github.com/k3s-io/k3s/releases/download/v1.24.4+k3s1/sha256sum-amd64.txt
[INFO] Downloading binary https://github.com/k3s-io/k3s/releases/download/v1.24.4+k3s1/k3s
[INFO] Verifying binary download
[INFO] Installing k3s to /usr/local/bin/k3s
[INFO] Skipping installation of SELinux RPM
[INFO] Creating /usr/local/bin/kubectl symlink to k3s
[INFO] Creating /usr/local/bin/crictl symlink to k3s
[INFO] Creating /usr/local/bin/ctr symlink to k3s
[INFO] Creating killall script /usr/local/bin/k3s-killall.sh
[INFO] Creating uninstall script /usr/local/bin/k3s-uninstall.sh
[INFO] env: Creating environment file /etc/systemd/system/k3s.service.env
[INFO] systemd: Creating service file /etc/systemd/system/k3s.service
[INFO] systemd: Enabling k3s unit
Created symlink /etc/systemd/system/multi-user.target.wants/k3s.service → /etc/systemd/system/k3s.service.
[INFO] systemd: Starting k3s
additionally, I have checked
sudo kubectl get nodes
and this worked perfectly
NAME STATUS ROLES AGE VERSION
ip-172-31-41-34 Ready control-plane,etcd,master 18m v1.24.4+k3s1
Now I am going to ssh into VM-2 and make it join the server running on VM-1
curl -sfL https://get.k3s.io | K3S_TOKEN=AtJMEyWR8pE3HR4RWgT6IsqglOkBm0sLC4n0aDBkng9VE1uqyNevR6oCMNCqQNaF sh -s - server --server https://65.0.54.158:6443
response
[INFO] Finding release for channel stable
[INFO] Using v1.24.4+k3s1 as release
[INFO] Downloading hash https://github.com/k3s-io/k3s/releases/download/v1.24.4+k3s1/sha256sum-amd64.txt
[INFO] Downloading binary https://github.com/k3s-io/k3s/releases/download/v1.24.4+k3s1/k3s
[INFO] Verifying binary download
[INFO] Installing k3s to /usr/local/bin/k3s
[INFO] Skipping installation of SELinux RPM
[INFO] Creating /usr/local/bin/kubectl symlink to k3s
[INFO] Creating /usr/local/bin/crictl symlink to k3s
[INFO] Creating /usr/local/bin/ctr symlink to k3s
[INFO] Creating killall script /usr/local/bin/k3s-killall.sh
[INFO] Creating uninstall script /usr/local/bin/k3s-uninstall.sh
[INFO] env: Creating environment file /etc/systemd/system/k3s.service.env
[INFO] systemd: Creating service file /etc/systemd/system/k3s.service
[INFO] systemd: Enabling k3s unit
Created symlink /etc/systemd/system/multi-user.target.wants/k3s.service → /etc/systemd/system/k3s.service.
[INFO] systemd: Starting k3s
Job for k3s.service failed because the control process exited with error code.
See "systemctl status k3s.service" and "journalctl -xe" for details
here is the contents of /var/log/syslog
Sep 6 19:10:00 ip-172-31-46-114 systemd[1]: Starting Lightweight Kubernetes...
Sep 6 19:10:00 ip-172-31-46-114 sh[9516]: + /usr/bin/systemctl is-enabled --quiet nm-cloud-setup.service
Sep 6 19:10:00 ip-172-31-46-114 sh[9517]: Failed to get unit file state for nm-cloud-setup.service: No such file or directory
Sep 6 19:10:00 ip-172-31-46-114 k3s[9520]: time="2022-09-06T19:10:00Z" level=info msg="Acquiring lock file /var/lib/rancher/k3s/data/.lock"
Sep 6 19:10:00 ip-172-31-46-114 k3s[9520]: time="2022-09-06T19:10:00Z" level=info msg="Preparing data dir /var/lib/rancher/k3s/data/577968fa3d58539cc4265245941b7be688833e6bf5ad7869fa2afe02f15f1cd2"
Sep 6 19:10:02 ip-172-31-46-114 k3s[9520]: time="2022-09-06T19:10:02Z" level=info msg="Starting k3s v1.24.4+k3s1 (c3f830e9)"
Sep 6 19:10:22 ip-172-31-46-114 k3s[9520]: time="2022-09-06T19:10:22Z" level=fatal msg="starting kubernetes: preparing server: failed to get CA certs: Get \"https://65.0.54.158:6443/cacerts\": context deadline exceeded (Client.Timeout exceeded while awaiting headers)"
Sep 6 19:10:22 ip-172-31-46-114 systemd[1]: k3s.service: Main process exited, code=exited, status=1/FAILURE
Sep 6 19:10:22 ip-172-31-46-114 systemd[1]: k3s.service: Failed with result 'exit-code'.
Sep 6 19:10:22 ip-172-31-46-114 systemd[1]: Failed to start Lightweight Kubernetes.
I am stuck at this for two days. I would really appreciate some help. Thank you.

How to start pyqt ui application using systemd

I have a pyqt5 UI application which I want to start using systemd service in raspberry pi. For this below is the service code:
[Unit]
Description=QT App
[Service]
User=pi
WorkingDirectory=/home/pi/Documents/qtproj
Environment=DISPLAY=:0
ExecStart=/bin/bash '/home/pi/Documents/qtproj/start_app.sh'
Restart=always
RestartSec=10s
[Install]
WantedBy=graphical.target
As per above code, I am starting start_app.sh script which loads few of the library and then finally start python3 pyqt5 application. When I am starting the above service, it stays in inactive status:
● myqt.service - QT App
Loaded: loaded (/etc/systemd/system/myqt.service; disabled; vendor preset: en
Active: inactive (dead)
Jul 13 09:47:57 pi systemd[1]: Started QT App.
Jul 13 09:47:57 pi sudo[7861]: pi : TTY=unknown ; PWD=/home/pi
Jul 13 09:47:57 pi sudo[7861]: pam_unix(sudo:session): session opened
Jul 13 09:47:58 pi bash[7860]: No protocol specified
Jul 13 09:47:58 pi bash[7860]: qt.qpa.screen: QXcbConnection: Could no
Jul 13 09:47:58 pi bash[7860]: Could not connect to any X display.
Jul 13 09:47:59 pi sudo[7861]: pam_unix(sudo:session): session closed
Jul 13 09:47:59 pi systemd[1]: myqt.service: Main process exited, code
Jul 13 09:47:59 pi systemd[1]: myqt.service: Failed with result 'exit-
Jul 13 09:48:05 pi systemd[1]: Stopped QT App
From the above status its clear that its not able to connect to display although I have give graphical.target. Can anyone please tell me how can I create a systemd service for pyqt5 application. Please help. Thanks
if it is a gui app (graphical USER interface), a logged in user is a requirement.
why not run it from a sytem wide .profile or similar for you system?
for bash that is /etc/profile.

While running Pact- Karma-Mocha framework, getting error - 'Can't find variable: Pact'

I am trying to get sample PACT JS framework (any variant) running for Contract testing. Initial plan is just to get the sample(s) provided get running & then later on make changes into End point and customise for our own purpose.
PACT Foundation link: https://github.com/pact-foundation/pact-js/tree/master/karma/mocha
Environment:
Win 7
Node: v8.11.4
dependencies installed:
"#pact-foundation/karma-pact": {
"version": "2.1.8",
"#pact-foundation/pact-node": {
"version": "6.19.11",
I am getting following error while trying to get it running.
Command: karma start karma.conf.js
C:\VarProjects\VanillaMocha>karma start test/karma.conf.js
10 09 2018 09:53:34.544:ERROR [config]: File C:\VarProjects\VanillaMocha\test\karma.conf.js does not exist!
C:\VarProjects\VanillaMocha>karma start karma.conf.js
[2018-09-10T08:53:42.384Z] INFO: pact-node#6.19.11/16892 on W5167037:
Creating Pact Server with options:
port = 1234,
consumer = KarmaMochaConsumer,
provider = KarmaMochaProvider,
logLevel = DEBUG,
log = C:\VarProjects\VanillaMocha\logs\pact.log,
dir = C:\VarProjects\VanillaMocha\pacts,
pactFileWriteMode = overwrite,
ssl = false,
cors = false,
host = localhost
[2018-09-10T08:53:42.401Z] INFO: pact-node#6.19.11/16892 on W5167037: Created 'standalone\win32-1.54.4\bin\pact-mock-service.bat service --port '1234' --consumer 'KarmaMochaConsumer
' --provider 'KarmaMochaProvider' --log-level 'DEBUG' --log 'C:\VarProjects\VanillaMocha\logs\pact.log' --pact_dir 'C:\VarProjects\VanillaMocha\pacts' --pact-file-write-mode 'overwri
te' --host 'localhost'' process with PID: 18912
10 09 2018 09:53:44.980:INFO [pact]: Pact Mock Server running on port: 1234
10 09 2018 09:53:45.054:WARN [watcher]: Pattern "C:/dist-web/pact-web.js" does not match any file.
10 09 2018 09:53:45.092:INFO [karma]: Karma v3.0.0 server started at http://0.0.0.0:9876/
10 09 2018 09:53:45.093:INFO [launcher]: Launching browser PhantomJS_without_security with unlimited concurrency
10 09 2018 09:53:45.101:INFO [launcher]: Starting browser PhantomJS
10 09 2018 09:53:46.811:INFO [PhantomJS 2.1.1 (Windows 7 0.0.0)]: Connected on socket qMhVUJZzdDCD_YuKAAAA with id 47921548
PhantomJS 2.1.1 (Windows 7 0.0.0) Client "before all" hook FAILED
Can't find variable: Pact
client-spec.js:10:32
PhantomJS 2.1.1 (Windows 7 0.0.0) Client "after all" hook FAILED
undefined is not an object (evaluating 'provider.finalize')
client-spec.js:21:28
PhantomJS 2.1.1 (Windows 7 0.0.0): Executed 2 of 4 (2 FAILED) ERROR (0.013 secs / 0.001 secs)
[2018-09-10T08:53:46.985Z] INFO: pact-node#6.19.11/16892 on W5167037: Removing all Pact servers.
[2018-09-10T08:53:46.986Z] INFO: pact-node#6.19.11/16892 on W5167037: Removing Pact with PID: 18912
C:\VarProjects\VanillaMocha>KARMA start
[2018-09-10T08:54:14.809Z] INFO: pact-node#6.19.11/7492 on W5167037:
Creating Pact Server with options:
port = 1234,
consumer = KarmaMochaConsumer,
provider = KarmaMochaProvider,
logLevel = DEBUG,
log = C:\VarProjects\VanillaMocha\logs\pact.log,
dir = C:\VarProjects\VanillaMocha\pacts,
pactFileWriteMode = overwrite,
ssl = false,
cors = false,
host = localhost
[2018-09-10T08:54:14.823Z] INFO: pact-node#6.19.11/7492 on W5167037: Created 'standalone\win32-1.54.4\bin\pact-mock-service.bat service --port '1234' --consumer 'KarmaMochaConsumer'
--provider 'KarmaMochaProvider' --log-level 'DEBUG' --log 'C:\VarProjects\VanillaMocha\logs\pact.log' --pact_dir 'C:\VarProjects\VanillaMocha\pacts' --pact-file-write-mode 'overwrit
e' --host 'localhost'' process with PID: 2920
10 09 2018 09:54:17.376:INFO [pact]: Pact Mock Server running on port: 1234
10 09 2018 09:54:17.447:WARN [watcher]: Pattern "C:/dist-web/pact-web.js" does not match any file.
10 09 2018 09:54:17.483:INFO [karma]: Karma v3.0.0 server started at http://0.0.0.0:9876/
10 09 2018 09:54:17.484:INFO [launcher]: Launching browser PhantomJS_without_security with unlimited concurrency
10 09 2018 09:54:17.489:INFO [launcher]: Starting browser PhantomJS
10 09 2018 09:54:19.243:INFO [PhantomJS 2.1.1 (Windows 7 0.0.0)]: Connected on socket rn-kwBRGhJbyUwvZAAAA with id 54614606
PhantomJS 2.1.1 (Windows 7 0.0.0) Client "before all" hook FAILED
Can't find variable: Pact
client-spec.js:10:32
PhantomJS 2.1.1 (Windows 7 0.0.0) Client "after all" hook FAILED
undefined is not an object (evaluating 'provider.finalize')
client-spec.js:21:28
PhantomJS 2.1.1 (Windows 7 0.0.0): Executed 2 of 4 (2 FAILED) ERROR (0.012 secs / 0 secs)
Kindly advise, Thanks a lot
The code is failing because it's missing pact-web. You can see this in the error message you included:
Pattern "C:/dist-web/pact-web.js" does not match any file.
This is happening because you're using the example karma.conf.js outside the example repository without modification.
Quoting the relevant part of karma.conf.js:
// if you are using this example to setup your own project
// load pact from the node_modules directory
'../../dist-web/pact-web.js',
// Example Using NPM package
// 'node_modules/#pact-foundation/pact-web/pact-web.js',
Looking at your directory structure, commenting this line:
'../../dist-web/pact-web.js',
and uncommenting this line:
// 'node_modules/#pact-foundation/pact-web/pact-web.js',
should solve your problem.
Note that you also need to ensure that #pact-foundation/pact-web is a dev-dependency:
npm install --save-dev '#pact-foundation/pact-web'

nodered on Raspberry PI is not starting any longer

I am not quite sure what node is causing this behaviour and there are tooo many flows so I can not install from scratch and yes I do not have a backup of them.
I realized today in the morning that I can not access the http gui of my nodered instance any longer on my raspberrypi zero. Just edited some flows but nothing real serious.
I am trying to start my node red on my Rapsberry PI zere and no GUI and UI is starting up to access the node red instance. I don't know how to solve and troubleshoot this. What I am doing or trying to do is:
pi#nodered-pi:~/.node-red $ node-red-start
Start Node-RED
Once Node-RED has started, point a browser at http://192.168.1.42:1880
On Pi Node-RED works better with the Firefox or Chrome browser
Use node-red-stop to stop Node-RED
Use node-red-start to start Node-RED again
Use node-red-log to view the recent log output
Use sudo systemctl enable nodered.service to autostart Node-RED at every boot
Use sudo systemctl disable nodered.service to disable autostart on boot
To find more nodes and example flows - go to http://flows.nodered.org
Starting as a systemd service.
Started Node-RED graphical event wiring tool.
19 Aug 15:13:55 - [info]
Welcome to Node-RED
===================
19 Aug 15:13:55 - [info] Node-RED version: v0.18.7
19 Aug 15:13:55 - [info] Node.js version: v8.11.1
19 Aug 15:13:55 - [info] Linux 4.14.52+ arm LE
19 Aug 15:14:06 - [info] Loading palette nodes
19 Aug 15:14:37 - [info] Dashboard version 2.9.6 started at /ui
19 Aug 15:14:49 - [warn] ------------------------------------------------------
19 Aug 15:14:49 - [warn] [node-red-contrib-delta-timed/delta-time] 'delta' already registered by module node-red-contrib-change-detect
19 Aug 15:14:49 - [warn] ------------------------------------------------------
19 Aug 15:14:49 - [info] Settings file : /home/pi/.node-red/settings.js
19 Aug 15:14:49 - [info] User directory : /home/pi/.node-red
19 Aug 15:14:49 - [warn] Projects disabled : set editorTheme.projects.enabled=true to enable
19 Aug 15:14:49 - [info] Flows file : /home/pi/.node-red/flows_nodered-pi.json
19 Aug 15:14:50 - [info] Server now running at http://127.0.0.1:1880/
19 Aug 15:14:50 - [warn]
---------------------------------------------------------------------
Your flow credentials file is encrypted using a system-generated key.
If the system-generated key is lost for any reason, your credentials
file will not be recoverable, you will have to delete it and re-enter
your credentials.
You should set your own key using the 'credentialSecret' option in
your settings file. Node-RED will then re-encrypt your credentials
file using your chosen key the next time you deploy a change.
---------------------------------------------------------------------
19 Aug 15:14:50 - [warn] Error loading credentials: SyntaxError: Unexpected token T in JSON at position 0
19 Aug 15:14:50 - [warn] Error loading flows: Error: Failed to decrypt credentials
19 Aug 15:14:51 - [info] Starting flows
19 Aug 15:15:01 - [warn] [telegram receiver:Telegram Receiver] bot not initialized
19 Aug 15:15:01 - [warn] [telegram sender:Temperatur Wetterstation] bot not initialized.
19 Aug 15:15:01 - [error] [function:Versorge mit Information] SyntaxError: Invalid or unexpected token
19 Aug 15:15:01 - [info] Started flows
19 Aug 15:15:02 - [info] [sonoff-server:166ef3ba.0029bc] SONOFF Server Started On Port 1080
19 Aug 15:15:02 - [red] Uncaught Exception:
19 Aug 15:15:02 - Error: listen EACCES 0.0.0.0:443
at Object._errnoException (util.js:1022:11)
at _exceptionWithHostPort (util.js:1044:20)
nodered.service: Main process exited, code=exited, status=1/FAILURE
nodered.service: Unit entered failed state.
nodered.service: Failed with result 'exit-code'.
nodered.service: Service hold-off time over, scheduling restart.
Stopped Node-RED graphical event wiring tool.
Started Node-RED graphical event wiring tool.
19 Aug 15:15:20 - [info]
Welcome to Node-RED
===================
19 Aug 15:15:20 - [info] Node-RED version: v0.18.7
19 Aug 15:15:02 - Error: listen EACCES 0.0.0.0:443
at Object._errnoException (util.js:1022:11)
at _exceptionWithHostPort (util.js:1044:20)
This error implies that something else is already running on port 443. This could be an existing copy of Node-RED or something else. You can search what applications are listening on what ports with the following command
lsof -i :443
This will list what is listening on port 443

Node-red email node keeps crashing

I have a simple email node and debug-node set-up within a web application using node red.
The email node has refresh time set to 5 seconds. and protocol IMAP.
I have a gmail account logged in.
Node-red crashes with the following error:
(Happens rather quickly when I receive an email with an attachment of > 10mb).
The TypeError is on different properties like 'name', 'type' '11456' etc...
10 Jul 17:00:28 - [info] Starting flows
10 Jul 17:00:28 - [info] Started flows
10 Jul 17:00:37 - [red] Uncaught Exception:
10 Jul 17:00:37 - TypeError: Cannot set property 'name' of undefined
at Connection.<anonymous> (/usr/lib/node_modules/node-red/node_modules/imap/lib/Connection.js:431:22)
at Connection._resTagged (/usr/lib/node_modules/node-red/node_modules/imap/lib/Connection.js:1535:22)
at Parser.<anonymous> (/usr/lib/node_modules/node-red/node_modules/imap/lib/Connection.js:194:10)
at emitOne (events.js:116:13)
at Parser.emit (events.js:211:7)
at Parser._resTagged (/usr/lib/node_modules/node-red/node_modules/imap/lib/Parser.js:175:10)
at Parser._parse (/usr/lib/node_modules/node-red/node_modules/imap/lib/Parser.js:139:16)
at Parser._tryread (/usr/lib/node_modules/node-red/node_modules/imap/lib/Parser.js:82:15)
at TLSSocket.Parser._cbReadable (/usr/lib/node_modules/node-red/node_modules/imap/lib/Parser.js:53:12)
at emitNone (events.js:106:13)
Versions:
10 Jul 17:00:27 - [info] Node-RED version: v0.18.7
10 Jul 17:00:27 - [info] Node.js version: v8.11.3
10 Jul 17:00:27 - [info] Linux 4.15.0-24-generic x64 LE
Package.json :
"dependencies": {
"imap": "^0.8.19",
"mailparser": "^0.6.2",
"nodemailer": "^1.11.0",